n = int(input()) p = list(map(int,input().split())) ans = 1 for i in p: ans *= i while( ans > 9): pre = 0 pre,ans = ans,pre while(pre > 0): ans += pre%10 pre //= 10 print(ans)