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
#include <bits/stdc++.h>
#define SIZE(a) ((int)(a.size()))

int main() {

	int n;
	std::cin >> n;

	std::vector<int> t(n + 1, 0);

	long long wynik = 0;

	int d_p = 0, d_n = 0;
	for(int i = 1; i <= n; i++) {
		int a;
		std::cin >> a;
		t[i] = a;
		while(a) {
			a /= 10;
			d_n++;
		}
		//std::cout << d_n << "\n";
		if(d_p > d_n) {
			int po = (int)std::pow(10, d_p - d_n);
			//std::cout << po << "\n";
			t[i] *= po;
			//t[i] += t[i - 1] % po;
			d_n += d_p - d_n; 
			wynik += d_p - d_n + 1;
			//std::cout << wynik << "\n";
		} else if(d_p == d_n) {
			if(t[i] <= t[i - 1]) {
				t[i] *= 10;
				d_n++;
				wynik += 1;
			//std::cout << wynik << "\n";
			}
		}

		d_p = d_n;
		d_n = 0;

	}

	//for(auto it : t) std::cout << it << " ";

	std::cout << wynik << "\n";


}