N = int(input()) P = list(map(int,input().split())) ans = 1 for i in P: ans *= i while ans >= 10: tmp = 0 for i in str(ans): tmp += int(i) ans = tmp print(ans)