#8 16 24 32 40 48 56 64 80
import sys
d={0:1 , 1:2 , 2:3 , 3:4 , 4:5 , 5:6 , 6:7 , 7:8 , 8:10}
l = int(input())
l = (l//8)
fl = list(map(int,input().split()))
for k in range(8,-1,-1):
if fl[k] != 0:
if d[k] > l:
print("NO SOLUTION!!")
sys.exit(0)
m=0
for i in range(9):
m = m + fl[i] * d[i]
print(m//l)