def bitsum(n): s = str(n) ret = 0 for i in s: ret += int(i) return ret N = int(input()) P = list(map(int,input().split())) now = 1 for i in range(N): now = bitsum(now) now *= P[i] while now >= 10: now = bitsum(now) print (now)