N = int(input()) P = list(map(int,input().split())) MOD = 10**9+7 K = 1 for p in P: K *= p K %= MOD l = list(str(K)) ans = 0 for k in l: ans += int(k) print(ans)