#P36. [KBC002C] Sequence 3
[KBC002C] Sequence 3
Source
This problem is adapted from Long Long OJ. All rights reserved.
Attention
P78 is the hard version of this problem.
Description
Given a sequence of integers, you need to add digits at the end of the integers in order to make the sequence strictly increasing.
Adding digit () at the end of a number can be represented as .
Find the minimum number of digits to be added.
Input
The first line consists of an integer .
The following lines consists of integers .
Output
Output the minimum number of digits to be added.
Samples
4
20
1
45
132
4
Tips
After adding digits, the sequence becomes .
Note that this is not the only possible solution.
For of the test cases:
- .
- .
For the remaining of the test cases:
- .
- All the numbers in are equal.