#include <bits/stdc++.h>
using namespace std;
pair < long long, long long > zn_d(long long x, long long y){
long long wyn = 1, c = 0;
while(x > y*wyn){
wyn*=10;
c++;
}
return {wyn, c};
}
long long znajdz(long long x, long long y, long long p){
//printf("%d\n",p);
while(p/10 > 0){
p/=10;
//printf(">>>%d %d\n",y+p-1, p);
while(y+p-1 < x){
y+=p;
}
//printf("oo %d\n",y);
}
return y;
}
int main(){
int n;
long long ost=0, ans=0;
scanf("%d",&n);
for(int i=0; i<n; i++){
long long x;
ost++;
scanf("%lld",&x);
auto pot = zn_d(ost, x);
//printf("%d %d %d\n",pot.first, pot.second, x*(pot.first/10)+(pot.first/10)-1 >= ost );
if(x*(pot.first/10)+(pot.first/10)-1 >= ost){
ans+=pot.second-1;
//printf(">>%d\n",ost);
ost = znajdz(ost, x*(pot.first/10), pot.first/10);
}
else{
ans+=pot.second;
ost = x*pot.first;
}
//printf(">%d\n",pot.second);
//ost = x;
}
printf("%lld\n",ans);
return 0;
}