N=int(input())
P=list(map(int,input().split()))

if 0 in P:
    print(0)
    exit(0)

K=1
for a in P:
    K=(K*a)%9
K=(K-1)%9+1
print(K)