Television
Task: Efficient Channel Switching
Nastya owns a TV with 100 channels, numbered from 0 to 99. She uses a remote control with 10 buttons labeled from 0 to 9 to change channels. The remote has two modes: A and B. In mode A, Nastya can switch to a channel by pressing a single digit button. In mode B, she can switch by pressing two buttons in sequence (e.g., pressing "0" followed by "5" changes to channel 5). The remote also has a "-" button to decrease the channel number by one (if the current channel is zero, it wraps around to 99), and a "+" button to increase the channel number by one. The "S" button toggles between modes A and B. Initially, the TV is set to channel zero, and the remote is in mode A.
After reviewing the TV schedule for a year, Nastya has compiled a list of channels she wants to watch in a specific order. To preserve her remote, she aims to minimize the number of button presses needed to follow this list. Your task is to help Nastya achieve this.
Input
The first line contains a single positive integer n, representing the number of channels in Nastya's list (1 ≤ n ≤ 100000). The second line contains n integers, indicating the sequence of channels Nastya wants to watch, separated by spaces. Each channel number is between 0 and 99 inclusive.
Output
Output a single integer m on the first line, representing the minimum number of button presses required to watch the channels in the specified order. On the second line, output m characters that detail the optimal sequence of button presses. If there are multiple optimal solutions, any one of them is acceptable.