import sys
sys.stdin = open('input.txt', 'r')
def getnum(li):
num = 0
for i in range(len(li)):
if li[i] == 1:
if (li[i-2] == 0) and (li[i-1] == 0) and (li[i+1] == 0) and (li[i+2] == 0):
num += 1
return num
for test in range(1, 11):
N = int(input())
arr = list(map(int, input().split()))
temp_list = []
copy_list = []
total_count = 0
for i in arr:
total_count += 1
copy_list = i.copy()
total = 1
result = 0
while total != 0:
temp_list = [0] * len(i)
for j in range(len(copy_list)):
if copy_list[j] != 0:
copy_list[j] -= 1
temp_list[j] += 1
result += getnum(temp_list)
total = 0
for x in copy_list:
if x != 0:
total += 1
print('#{} {}'.format(total_count, result))