n = int(input()) p = list(map(int,input().split())) ans = 1 for i in range(n): ans *= p[i] while ans >= 10: str_ans = str(ans) str_ans_list = list(str_ans) wa = 0 for j in range(len(str_ans_list)): wa += int(str_ans_list[j]) ans = wa print(ans)