N = int(input()) P = list(map(int,input().split())) def calc(K): ans = 0 while K: ans += K % 10 K = K // 10 return ans K = 1 for i in P: K *= i while K >= 10: K = calc(K) print(K)