s = input() s_sp = [int(a) for a in s] N = int(s_sp.pop(0)) kai = 0 for i in range(N): for j in range(N): lef = i-j rig = int(s_sp[i])-int(s_sp[j]) kai += lef*rig print(kai)