1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <string>

using namespace std;


void func2B()
{
	int n = 0;

	int sum = 0;

	long long cur = 0;
	long long prev = 0;

	cin >> n;
	
	while ( n > 0 )
	{
		cin >> cur;

		int curSum = 0;
		long long newCur = cur;
		while ( newCur <= prev )
		{
			curSum++;
			newCur = newCur * 10 + 9;
		}
		sum += curSum;

		newCur = cur;
		for ( int i = 0; i < curSum; i++ )
		{
			newCur *= 10;
		}

		if ( newCur > prev )
		{
			prev = newCur;
		}
		else
		{
			prev = prev + 1;
		}

		n--;
	}

	cout << sum;
	cout << "\n";
}

int main()
{
	func2B();
	return 0;
}