dummy-4
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

Its NU-Tech'15 and participants are pouring in large numbers. Its the first day of the fest and everybody has gathered around the registration desks but are confused on receiving a set of very large numbers on the registration slip. They are later told by the volunteers that in order to get their respective registration numbers, they are supposed to add all the numbers, then add the digits of the sum and the then again add the digits of the new sum and continue till the answer consists of a single digit. That digit is their Registration ID. Help the participants to decipher their NU-Tech Ids.

Input:

First line contains an integer n. n lines follow each containing a "Large Number".

Output:

Print the Registration IDs of the student.

Constraints:

1 ≤ n ≤500

1 ≤ Large Number ≤ 2^1000

SAMPLE INPUT
2
23
99

SAMPLE OUTPUT
5


def solve(n):
	while True:
		temp=n
		s=0
		while temp:
			s+=temp%10
			temp/=10
		n=s
		
		if n<10:
			break
	
	print(n)
	
n=0
for _ in range(eval(input())):
	m=eval(input())
	n+=m
solve(n)


a=input()
l=[]
for i in range(int(a)):
	b=int(input())
	l.append(b)

n=sum(l)

def sum_digits(n):
	n = str(n)
	if int(n) < 10:
		return int(n)
	else:
		count = 0
		for c in n:
			count += int(c)
	return sum_digits(int(count))

print(sum_digits(n))


case = int(input())
lst = []

def num_sum(n):
	st = str(n)
	ln = len(st)
	val = False
	total = 0
	for i in range(0, ln):
		total += int(st[i])
	return total

def one_check(num):
	val = False
	if(len(str(num)) == 1):
		val = True
	else:
		val = False
	return val
		
for i in range(0, case):
	num = int(input())
	lst.append(num)
	total = sum(lst)
while(1):
	total = num_sum(total)
	if(one_check(total)):
		print(total)
		break
	else:
		continue