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