# たとえば12*23=(10+2)*(20+3)、桁和を求めるということは10は意味がなくなるので(1+2)*(2+3)となる # つまり各数字の桁和の積でいいはず、式変形 N = int(input()) P = list(map(int, input().split())) def digitsum(n): calc = 0 for s in str(n): calc += int(s) return calc #digitsum(12) P2 = [] for p in P: P2.append(digitsum(p)) #print(P2) product = 1 for p in P2: product *= p #print(product) current = product while len(str(current))>1: current = digitsum(current) print(current)