n=int(input()) P=list(map(int,input().split())) cnt=1 for i in range(n): cnt*=P[i]%9 print(cnt%9)