N = int(input()) L = list(map(int,input().split())) ans = 0 for i in range(N): ans = (ans+L[i])%9 if L.count(0): print(0) else: print(ans)