n=int(input()) p=list(map(int,input().split())) a=1 for i in p:a*=i while a>9: b=0 for i in str(a):b+=int(i) a=b print(a)