n=int(input())
l=list(input().strip().split())
sum=0
dic={}
for i in range(n):
    if len(l[i]) in dic:
        dic[len(l[i])]+=1
    else:
        dic[len(l[i])]=1

def calc(a,k):
    a0=a[-k:]
    a1=a[:-k]
    A1=0
    if a1!='':
        A1=int(a1)*(10**(k*2))*2
    ans=''
    for k in a0:
        ans+=k*2
    return A1+int(ans)
for i in range(n):
    for k in dic:
        sum+=calc(l[i],k)
print(sum)
