#探寻数学奥秘,给出n判断多少位小于n,已AC raw=long(raw_input()) a=[] for i in range(0,raw): num=long(raw_input()) a.append(num) for i in a: x=[x for x in range(1,i+1)] s=[str(j) for j in x] ls3 = ''.join(s) print len(ls3)