# 入力例2の言葉はいけない # 難しいのは最初の掛け算だけ、あとは簡単 # 解き方が思いつかないので実験してみた # かける数字同士の各桁をかけた和を使えばいいか N = int(input()) P = list(map(int, input().split())) product = P[0] for i in range(1, N): list1 = [] for p1 in str(product): list1.append(int(p1)) list2 = [] for p2 in str(P[i]): list2.append(int(p2)) product = 0 for p1 in list1: for p2 in list2: product += p1*p2 #print(product) while True: temp = 0 for s in str(product): temp += int(s) #print(temp) if len(str(temp)) == 1: break else: product = temp print(temp)