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) while len(str(ans)) > 1: count = 0 l = list(str(ans)) for k in l: count += int(k) ans = count print(ans)