N=int(input()) P=list(map(int,input().split())) temp=1 for p in P: temp*=p ans=0 temp=list(str(temp)) for item in temp: ans+=int(item) print(ans%9)