def sum_digit(x):
sum = 0
while(x>0):
r = x%10
sum+=r
x = x // 10
return sum
tc = int(input())
num = 0
while(tc):
x = int(input())
num+= x
tc-=1
while(num>9):
num = sum_digit(num)
print(num)