N = int(input())
K = 7
Buf = [0]*K
for i in range(N):
elem = int(input())
next = Buf[i % K]
Buf[i % K] = elem
if i == K:
maxPrev = next
maxSum = next + elem
if i > K:
maxPrev = max(maxPrev, next)
maxSum = max(maxSum, maxPrev+elem)