import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) P=[int(i) for i in input().split()] def tot(x): while x>=10: res=0 for xx in str(x): res+=int(xx) x=res return x ans=1 for p in P: ans=tot(ans*p) print(ans)