n=int(input())
listc=list(map(int,input().split()))
lists=[5]*20
flag=-1
flagg=-1
o=-1
for a in listc:
for i in range(20):
if a<=lists[i] and flag==-1 and o==-1:
temp=i*5+(5-lists[i])
for k in range(a):
temp+=1
print( temp,end=" ")
lists[i]=lists[i]-a
flag=0
flagg=0
flag=-1
if flagg==-1:
o=0
for i in range(20):
if a>0 and a>lists[i] and lists[i]!=0:
temp=i*5+(5-lists[i])
for p in range(lists[i]):
temp+=1
print(temp,end=" ")
a-=lists[i]
lists[i]=0
if a>0 and a<=lists[i] and lists[i]!=0:
temp=i*5+(5-lists[i])
for p in range(a):
temp+=1
print(temp,end=" ")
lists[i]=5-a
a=0
flagg=-1
o=-1
print("")