N = int(input()) P = list(map(int,input().split())) def f(x): x = str(x) if len(x)==1:return int(x) res = 0 for i in range(len(x)): res += int(x[i]) return f(res) ans = 1 for i in range(N): ans = f(ans*f(P[i])) print(ans)