import math n = int(input()) p = list(map(int, input().split())) k = 0 for i in range(n): k += p[i] while k >= 10: l = k s = 0 while l > 0: s += l % 10 l //= 10 k = s print(k)