from sys import stdin def digitSum(n): # 数値を文字列に変換 s = str(n) # 1文字ずつ数値化し配列にする。 array = list(map(int, s)) # 合計値を返す return sum(array) n = int(input()) a = list(map(int,input().split())) tmp=1 for i in range(n) : tmp = tmp * a[i] while tmp>9: tmp = digitSum(tmp) print(tmp)