Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.  [Image] 

Initially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.

Note that the counter-clockwise order means if the player takes the stones from hole $i$, he will put one stone in the $(i+1)$-th hole, then in the $(i+2)$-th, etc. If he puts a stone in the $14$-th hole, the next one will be put in the first hole.

After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.

Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.


-----Input-----

The only line contains 14 integers $a_1, a_2, \ldots, a_{14}$ ($0 \leq a_i \leq 10^9$) — the number of stones in each hole.

It is guaranteed that for any $i$ ($1\leq i \leq 14$) $a_i$ is either zero or odd, and there is at least one stone in the board.


-----Output-----

Output one integer, the maximum possible score after one move.


-----Examples-----
Input
0 1 1 0 0 0 0 0 0 7 0 0 0 0

Output
4

Input
5 1 1 1 1 0 0 0 0 0 0 0 0 0

Output
8



-----Note-----

In the first test case the board after the move from the hole with $7$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $4$.

Difficulty: EASY
Tags: Implementation

Complete search
Skill types: Complete search
Expected Time Complexity: O(1)

Starter code:

Solutions:
a = list(map(int, input().split()))
m = 0
for i in range(len(a)):
	ai = a[i]
	giri = int(ai / 14)
	modulo = ai % 14
	tmp = a[i]
	a[i] = 0
	s = 0
	for j in range(len(a)):
		if (a[j] + giri) % 2 == 0:
			s += a[j] + giri
	j = (i + 1) % 14
	cont = 1
	while cont <= modulo:
		if (a[j] + giri) % 2 != 0:
			s += a[j] + giri + 1
		else:
			s -= a[j] + giri
		cont += 1
		j = (j + 1) % 14
	a[i] = tmp
	m = max(s, m)
print(m)


b = list(map(int, input().split()))
ans = 0
for i in range(14):
	a = b.copy()
	x = a[i]
	if x == 0:
		continue
	a[i] = 0
	tmp = x // 14
	rem = x % 14
	for j in range(14):
		a[j] += tmp
	for j in range(rem):
		a[(i + j + 1) % 14] += 1
	tans = 0
	for c in a:
		if c & 1 == 0:
			tans += c
	ans = max(ans, tans)
print(ans)


board = list(map(int, input().split(' ')))
max_score = 0
for i in range(len(board)):
	if board[i] == 0:
		continue
	next_board = board[:]
	next_board[i] = 0
	increase_amount = int(board[i] / len(board))
	extra = board[i] % len(board)
	for ni in range(len(next_board)):
		next_board[ni] += increase_amount
	for e in range(1, extra + 1):
		next_board[(i + e) % len(next_board)] += 1
	cur_score = 0
	for c in next_board:
		if c % 2 == 0:
			cur_score += c
	max_score = max(max_score, cur_score)
print(max_score)


def ii():
	return int(input())

def mi():
	return list(map(int, input().split()))

def li():
	return list(mi())
a = li()
ans = 0
for i in range(14):
	if a[i] == 0:
		continue
	q = a[i] // 14
	r = a[i] % 14
	b = [x + q for x in a]
	b[i] = q
	for j in range(r):
		b[(i + 1 + j) % 14] += 1
	ans = max(ans, sum((x for x in b if x % 2 == 0)))
print(ans)


n = 14
a = None

def checkCase(defList, i):
	global n
	a = list(defList)
	stone = a[i] % n
	stoneAll = a[i] // n
	a[i] = 0
	j = i + 1
	while stone > 0:
		if j >= n:
			j = 0
		a[j] += 1
		j += 1
		stone -= 1
	pickedUp = 0
	for k in range(n):
		a[k] += stoneAll
		if a[k] % 2 == 0:
			pickedUp += a[k]
	return pickedUp

def main():
	global n, a
	a = [int(e) for e in input().split()]
	maxStones = 0
	for i in range(n):
		if a[i] > 0:
			maxStones = max(maxStones, checkCase(a, i))
	print(maxStones)
main()


a = [int(i) for i in input().split()]
ans = 0
for i in range(14):
	if a[i] > 0:
		b = a[:]
		tmp = a[i]
		b[i] = 0
		for j in range(i + 1, 14):
			b[j] += 1
			tmp -= 1
			if tmp == 0:
				break
		for j in range(14):
			b[j] += tmp // 14
		for j in range(tmp % 14):
			b[j] += 1
		sum = 0
		for j in range(14):
			if b[j] % 2 == 0:
				sum += b[j]
		ans = max(sum, ans)
print(ans)


def get_res(L):
	A = L[:]
	best = 0
	for i in range(1, 15):
		A = L[:]
		res = 0
		N = L[i - 1]
		A[i - 1] = 0
		for j in range(i, 14):
			if N > 0:
				A[j] += 1
				N -= 1
		delta = N // 14
		rem = N % 14
		for j in range(1, 15):
			A[j - 1] += delta
		k = 1
		while rem > 0:
			A[k - 1] += 1
			k += 1
			rem -= 1
		res = sum([x for x in A if x % 2 == 0])
		if res > best:
			best = res
	return best
L = [int(s) for s in input().split(' ')]
result = get_res(L)
print('{}'.format(result))


A = list(map(int, input().split()))
X = []
for i in range(14):
	if A[i]:
		B = A[:]
		(x, y) = divmod(B[i], 14)
		B[i] = 0
		for j in range(14):
			B[j] += x
		for j in range(i - 13, y + i - 13):
			B[j] += 1
		X.append(sum((b for b in B if not b % 2)))
print(max(X))


arr = list(map(int, input().split()))
ans = 0
for i in range(14):
	r = arr[i] // 14
	d = arr[i] % 14
	c = 0
	x = (i + 1) % 14
	s = 0
	temp2 = arr[i]
	arr[i] = 0
	while c < 14:
		c += 1
		temp = arr[x] + r
		if d > 0:
			temp += 1
		d -= 1
		x = (x + 1) % 14
		s += 0 if temp % 2 else temp
	arr[i] = temp2
	ans = max(ans, s)
print(ans)


desk = list(map(int, input().split()))
resalts = [0] * 14
deck = [0] * 14
for i in range(14):
	deck[i] = desk[i]

def move(walk, start):
	wask = [0] * 14
	for i in range(14):
		wask[i] = walk[i]
	resalt = 0
	stones = wask[start]
	wask[start] = 0
	al = stones // 14
	stones = stones % 14
	for i in range(14):
		wask[i] += al
	for i in range(stones):
		now = start + i + 1
		if now > 13:
			now = now % 14
		wask[now] += 1
	for i in range(14):
		if wask[i] % 2 == 0:
			resalt += wask[i]
			wask[i] = 0
	wask = walk
	return resalt
for i in range(14):
	if desk[i] > 0:
		resalts[i] = move(deck, i)
	deck = desk
print(max(resalts))


arr = list(map(int, input().split()))
summ = 0
for i in range(14):
	copy = [0] * 14
	now = arr[i]
	for j in range(14):
		copy[j] = arr[j]
	copy[i] = 0
	for k in range(i + 1, 14):
		if now <= 0:
			break
		copy[k] += 1
		now -= 1
	s = now // 14
	for k in range(14):
		copy[k] += s
	for k in range(now % 14):
		copy[k] += 1
	local_s = 0
	for el in copy:
		if el > 0 and el % 2 == 0:
			local_s += el
	if local_s > summ:
		summ = local_s
print(summ)


init_stone = list(map(int, input().split()))
max_score = -1
for i in range(14):
	released = init_stone[i] // 14
	leftover = init_stone[i] % 14
	res_stone = list(init_stone)
	res_stone[i] = 0
	for j in range(1, leftover + 1):
		res_stone[(i + j) % 14] += 1
	score = 0
	for j in range(14):
		if (res_stone[j] + released) % 2 == 0:
			score += res_stone[j] + released
	if max_score < score:
		max_score = score
print(max_score)


s = [int(i) for i in input().split()]
y = 0
for i in range(14):
	u = s[:]
	t = s[i]
	u[i] = 0
	ans = 0
	for c in range(14):
		u[c] += t // 14
		if (c - i - 1) % 14 < t % 14:
			u[c] += 1
		if u[c] % 2 == 0:
			ans += u[c]
	y = max(ans, y)
print(y)


l = list(map(int, input().split()))
l *= 2
ans = 0
for i in range(14):
	s = 0
	if l[i] != 0:
		a = l[i]
		x = l[i] % 14
		y = l[i] // 14
		l[i] = 0
		l[i + 14] = 0
		for j in range(1, 15):
			if j <= x:
				if (l[j + i] + 1 + y) % 2 == 0:
					s += l[j + i] + 1 + y
			elif (l[j + i] + y) % 2 == 0:
				s += l[j + i] + y
		l[i] = a
		l[i + 14] = a
		ans = max(ans, s)
print(ans)


a = list(map(int, input().split()))
res = 0
for i in range(14):
	if a[i] == 0:
		continue
	d = a[i] // 14
	r = a[i] % 14
	b = a.copy()
	b[i] = 0
	ans = 0
	for j in range(1, r + 1):
		b[(i + j) % 14] += 1
	for j in range(0, 14):
		b[j] += d
		if b[j] % 2 == 0:
			ans += b[j]
	if ans > res:
		res = ans
print(res)


l = [int(i) for i in input().split()]
zuida = 0
for i in range(14):
	s = l.copy()
	j = s[i] % 14
	k = s[i] // 14
	s[i] = 0
	for h in range(14):
		s[h] = s[h] + k
	for h in range(i + 1, i + 1 + j):
		s[h % 14] = s[h % 14] + 1
	zuida = max(zuida, sum([h if h % 2 == 0 else 0 for h in s]))
print(zuida)


data = list(map(int, input().split()))
ans = 0

def solve_for(ind):
	x = data[ind]
	new_data = [el for el in data]
	if x == 0:
		return 0
	new_data[ind] = 0
	each = x // 14
	x %= 14
	for i in range(14):
		new_data[i] += each
	for i in range(ind + 1, 14):
		new_data[i] += 1 if x > 0 else 0
		x -= 1
	for i in range(ind + 1):
		new_data[i] += 1 if x > 0 else 0
		x -= 1
	answ = 0
	for el in new_data:
		answ += el if el % 2 == 0 else 0
	return answ
for i in range(14):
	ans = max(ans, solve_for(i))
print(ans)


def fun(l):
	return sum(list(filter(lambda x: x % 2 == 0, l)))
l = list(map(lambda x: int(x), input().split()))
ans = 0
for i in range(14):
	tmp = l[:]
	tmp[i] = 0
	for j in range(i + 1, i + 15):
		tmp[j % 14] += l[i] // 14
	for j in range(i + 1, i + 1 + l[i] % 14):
		tmp[j % 14] += 1
	ans = max(ans, fun(tmp))
print(ans)


import sys
lines = sys.stdin.readlines()
cur_line = -1

def input():
	global lines, cur_line
	cur_line += 1
	return lines[cur_line][:-1]

def test(n, i):
	base = n[i] // 14
	diff = n[i] - base * 14
	n[i] = 0
	for k in range(14):
		n[k] += base
	for j in range(1, diff + 1):
		n[(i + j) % 14] += 1
	return sum((k for k in n if k % 2 == 0))
n = list(map(int, input().split()))
print(max((test(n[:], k) for k in range(14))))


A = list(map(int, input().split()))
score = 0
for i in range(14):
	score = max(score, sum([j for j in [(A[j] if i != j else 0) + A[i] // 14 + (1 if (j + 13 - i) % 14 < A[i] % 14 else 0) for j in range(14)] if j % 2 == 0]))
print(score)


holes = list(map(int, input().split()))
n = 14
m = 0
for i in range(n):
	temp = holes[:]
	x = temp[i]
	temp[i] = 0
	for j in range(n):
		temp[j] += x // n
	x %= n
	while x:
		i = (i + 1) % n
		temp[i] += 1
		x -= 1
	m = max(m, sum((x for x in temp if x & 1 < 1)))
print(m)


l = list(map(int, input().split()))

def ans(x):
	if l[x] == 0:
		return (0, [])
	cnt = 0
	m = []
	vx = l[x]
	for i in l:
		m.append(i)
	m[x] = 0
	while x < 13 and vx > 0:
		x += 1
		m[x] += 1
		vx -= 1
	if vx > 14:
		f = vx // 14
		for i in range(14):
			m[i] += f
		vx -= f * 14
	while vx > 0:
		x += 1
		m[x % 14] += 1
		vx -= 1
	for i in m:
		if i % 2 == 0:
			cnt += i
	return (cnt, m)
answers = []
for i in range(14):
	a = ans(i)
	x = a[0]
	y = a[1]
	answers.append(x)
print(max(answers))


from copy import copy
a = list(map(int, input().split()))
ans = 0
for i in range(14):
	b = copy(a)
	b[i] = 0
	for j in range(1, 14 + 1):
		b[(i + j) % 14] += (a[i] - 1) // 14 + ((a[i] - 1) % 14 + 1 > j - 1)
	ans = max(ans, sum((el * (el % 2 == 0) for el in b)))
print(ans)


def count(idx, nums):
	val = nums[idx]
	nums[idx] = 0
	suma = 0
	for i in range(1, 15):
		x = nums[(idx + i) % 14] + (val - i + 1 + 13) // 14
		if x % 2 == 0:
			suma += x
	nums[idx] = val
	return suma
nums = list(map(int, input().strip().split()))
maxi = 0
for i in range(len(nums)):
	maxi = max(maxi, count(i, nums))
print(maxi)


import os
import sys
from io import BytesIO, IOBase
from collections import *
from itertools import *
from functools import *
from math import *
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
A = [int(n) for n in input().split()]
N = len(A)
dp = [0] * N
for i in range(N):
	B = A.copy()
	each = B[i] // N
	curr = B[i]
	B[i] = 0
	for j in range(N):
		B[j] += each
	for j in range(1, curr - each * N + 1):
		B[(i + j) % N] += 1
	for M in B:
		if M % 2 == 0:
			dp[i] += M
print(max(dp))


stones = list(map(int, input().split()))
initial_sum = 0

def even_sum(arr):
	temp_sum = 0
	for each in arr:
		if each % 2 == 0:
			temp_sum += each
	return temp_sum
initial_sum = even_sum(stones)
dup_sum = initial_sum
for i in range(14):
	duplicate = list(stones)
	temp = stones[i]
	duplicate[i] = 0
	j = i
	for each in range(14):
		duplicate[each] += temp // 14
	temp = temp % 14
	while temp > 0:
		if j == 13:
			j = -1
		j += 1
		duplicate[j] += 1
		temp -= 1
	ts = even_sum(duplicate)
	if ts > initial_sum:
		initial_sum = ts
print(initial_sum)


def score(l):
	return sum((x * (x % 2 == 0) for x in l))
res = 0
ns = list(map(int, input().split()))
for i in range(14):
	l = list(ns)
	for j in range(13):
		l[(i + 1 + j) % 14] += l[i] // 14 + (1 if j + 1 <= l[i] % 14 else 0)
	l[i] = l[i] // 14
	res = max(res, score(l))
print(res)


l = input().split()
for i in range(14):
	l[i] = int(l[i])
last = list()
for i in range(14):
	k = list()
	jav = 0
	for j in range(14):
		if i != j:
			k.append(int(l[i] / 14) + l[j])
		else:
			k.append(int(l[i] / 14))
	for t in range(l[i] % 14):
		k[(i + t + 1) % 14] += 1
	for a in range(14):
		if k[a] % 2 == 0:
			jav += k[a]
	last.append(jav)
	del k
print(max(last))


a = list(map(int, input().split()))
ans = 0
for i in range(14):
	b = a[:]
	res = 0
	b[i] = 0
	for j in range(i + 1, 14):
		b[j] += int(a[i] >= j - i)
	for j in range(14):
		b[j] += max(a[i] - (13 - i), 0) // 14 + int(max(a[i] - (13 - i), 0) % 14 >= j + 1)
		if b[j] % 2 == 0:
			res += b[j]
	ans = max(ans, res)
print(ans)


a = list(map(int, input().split()))
mx = 0
for i in range(14):
	c = a[i]
	b = a[:]
	b[i] = 0
	res = 0
	for j in range(1, 15):
		b[(i + j) % 14] += c // 14
		if c % 14 >= j:
			b[(i + j) % 14] += 1
		if b[(i + j) % 14] % 2 == 0:
			res += b[(i + j) % 14]
	mx = max(res, mx)
print(mx)


import copy
R = lambda : map(int, input().split())
s = list(R())
r = 0
for i in range(14):
	a = s[i]
	if a != 0:
		s1 = s.copy()
		s1[i] = 0
		(a1, a2) = (a // 14, a % 14)
		s2 = [a1 + 1] * a2
		s2.extend([a1] * (14 - a2))
		s3 = s1[i + 1:14]
		s3.extend(s1[0:i + 1])
		r1 = sum(list(filter(lambda x: x % 2 == 0, map(lambda x: sum(x), zip(s2, s3)))))
		r = max(r, r1)
print(r)


holes = list(map(int, input().split()))
mx = -1
for i in range(14):
	if holes[i] > 0:
		temp2 = holes[i]
		temp = list(holes)
		temp[i] = 0
		ext = temp2 // 14
		for j in range(14):
			temp[j] += ext
		temp2 = temp2 % 14
		while temp2 > 0:
			if i + 1 == 14:
				i = 0
			else:
				i += 1
			temp[i] += 1
			temp2 -= 1
		sm = 0
		for i in temp:
			if i % 2 == 0:
				sm += i
		mx = max(mx, sm)
print(mx)


a = list(map(int, input().split()))
count = 0
max_count = 0
for i in range(14):
	b = []
	for l in range(14):
		b.append(a[l])
	n = b[i]
	b[i] = 0
	if n > 0:
		for j in range(i + 1, i + 1 + n % 14):
			b[j % 14] += n // 14 + 1
		for h in range(i + 1 + n % 14, 14 + i + 1):
			b[h % 14] += n // 14
		for k in range(14):
			if b[k] % 2 == 0:
				count += b[k]
		max_count = max(count, max_count)
		count = 0
print(max_count)


a = list(map(int, input().split()))

def f(i, ai):
	if not ai:
		return 0
	b = list(a)
	b[i] = 0
	for j in range(14):
		b[j] += ai // 14
	for j in range(ai % 14):
		b[(i + j + 1) % 14] += 1
	return sum((bj for (j, bj) in enumerate(b) if bj % 2 == 0))
print(max((f(i, ai) for (i, ai) in enumerate(a))))


from sys import stdin, stdout
arr = [int(x) for x in stdin.readline().split()]

def f(arr, index):
	val = arr[index]
	arr[index] = 0
	add = int(val / 14)
	val %= 14
	ans = 0
	for i in range(1, val + 1):
		arr[(index + i) % 14] += 1
	for i in range(0, 14):
		arr[i] += add
		if arr[i] % 2 == 0:
			ans += arr[i]
	return ans
ans = 0
for a in range(0, 14):
	ans = max(ans, f(arr[:], a))
stdout.write(str(ans))


import sys, copy
arr = list(map(int, sys.stdin.readline().split()))
ans = 0
for i in range(14):
	temp = copy.deepcopy(arr)
	val = arr[i]
	temp[i] = 0
	for j in range(14):
		temp[j] += val // 14
	val %= 14
	idx = (i + 1) % 14
	while val > 0:
		temp[idx] += 1
		val -= 1
		idx = (idx + 1) % 14
	res = 0
	for i in temp:
		if i % 2 == 0:
			res += i
	ans = max(ans, res)
print(ans)


m = list(map(int, input().split()))
mx = 0
for i in range(14):
	if m[i] == 0:
		continue
	e = m[i] // 14
	k = m[i] % 14
	g = [x + e for x in m]
	g[i] -= m[i]
	for u in range(i + 1, min(14, k + i + 1)):
		g[u] += 1
	for u in range(0, k + i - 13):
		g[u] += 1
	s = 0
	for d in g:
		if not d % 2:
			s += d
	mx = max(mx, s)
print(mx)


a = list(map(int, input().split()))
ans = 0
for i in range(14):
	if a[i] != 0:
		u = a[:]
		for j in range(u[i] % 14):
			u[(j + i + 1) % 14] += 1
		k = u[i] // 14
		u[i] = 0
		for j in range(14):
			u[j] += k
		m = 0
		for i in range(14):
			if u[i] % 2 == 0:
				m += u[i]
		if m > ans:
			ans = m
print(ans)


def main():
	(aa, res) = (list(map(int, input().split())), [])
	for (i, a) in enumerate(aa):
		if not a:
			continue
		bb = aa[:]
		(a, r) = divmod(a, 14)
		bb[i] = 0
		for j in range(1, 15):
			bb[(i + j) % 14] += a + (j <= r)
		res.append(sum((a for a in bb if not a & 1)))
	print(max(res))
main()


a = list(map(int, input().split()))
ma = 0
for i in range(14):
	b = []
	ans = 0
	for k in range(len(a)):
		b.append(a[k])
	if a[i] < 14:
		b[i] = 0
		for j in range(a[i]):
			b[int((i + j + 1) % 14)] += 1
		for i in range(len(b)):
			if b[i] % 2 == 0:
				ans += b[i]
		ma = max(ma, ans)
	else:
		b[i] = 0
		p = a[i] // 14
		for j in range(14):
			b[j] += p
		for j in range(a[i] % 14):
			b[int((i + j + 1) % 14)] += 1
		for i in range(len(b)):
			if b[i] % 2 == 0:
				ans += b[i]
		ma = max(ma, ans)
print(ma)


l = list(map(int, input().split()))
ans = []
for i in range(14):
	b = list(l)
	count = 0
	if l[i] > 0:
		abc = b[i]
		b[i] = 0
		x = b[i:] + b[:i]
		if l[i] <= 13:
			for j in range(1, l[i] + 1):
				x[j] += 1
			for j in x:
				if j % 2 == 0:
					count += j
			ans.append(count)
		else:
			for j in range(1, 14):
				x[j] += 1
			abc -= 13
			z = abc // 14
			p = abc % 14
			for j in range(14):
				x[j] += z
			for j in range(p):
				x[j] += 1
			for j in x:
				if j % 2 == 0:
					count += j
			ans.append(count)
print(max(ans))


a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
	x = a[i]
	b = [j for j in a]
	b[i] = 0
	for j in range(len(a)):
		b[j] += x // 14
	for j in range(1, x % 14 + 1):
		b[(i + j) % 14] += 1
	ans_now = 0
	for j in b:
		if j % 2 == 0:
			ans_now += j
	ans = max(ans_now, ans)
print(ans)


def scor(a):
	s = 0
	for i in range(0, 14):
		if a[i] % 2 == 0:
			s += a[i]
	return s
a = list(map(int, input().split()))
ac = a.copy()
n = 14
maxim = 0
for x in range(14):
	if a[x] != 0:
		m = a[x]
		a[x] = 0
		for i in range(n):
			a[i] += m // n
		m %= n
		while m:
			x = (x + 1) % n
			a[x] += 1
			m -= 1
		if maxim < scor(a):
			maxim = scor(a)
	a = ac.copy()
print(maxim)


m = list(map(int, input().split(' ')))

def sum_even(ar):
	s = 0
	for el in ar:
		if el % 2 == 0:
			s += el
	return s
ans = 0
for i in range(14):
	plus_all = m[i] // 14
	plus_other = m[i] % 14
	new_f = m[:]
	new_f[i] = 0
	for j in range(14):
		new_f[j] += plus_all
	for k in range(plus_other):
		new_f[(i + k + 1) % 14] += 1
	ans = max(ans, sum_even(new_f))
print(ans)


l = [int(x) for x in input().split()]
maxans = 0
for i in range(14):
	l2 = l[:]
	num = l[i]
	l2[i] = 0
	for ii in range(14):
		l2[ii] += num // 14
	rem = num % 14
	j = i + 1
	while rem:
		l2[j % 14] += 1
		j += 1
		rem -= 1
	summ = 0
	for ele in l2:
		if ele % 2 == 0:
			summ += ele
	maxans = max(maxans, summ)
print(maxans)


def main():
	a = [int(i) for i in input().split(' ')]
	ans = 0
	for i in range(14):
		if a[i] == 0:
			continue
		b = a.copy()
		k = a[i] // 14
		r = a[i] % 14
		b[i] = 0
		for j in range(14):
			b[j] += k
		for j in range(r):
			b[(i + 1 + j) % 14] += 1
		score = 0
		for x in b:
			if x % 2 == 0:
				score += x
		ans = max(ans, score)
	print(ans)
main()


a = [int(x) for x in input().split()]
maxeven = 0
for i in range(len(a)):
	maxthis = 0
	b = [0] * 14
	for j in range(14):
		b[j] = a[j] + a[i] // 14
	b[i] -= a[i]
	for j in range(a[i] % 14):
		b[(i + j + 1) % 14] += 1
	for j in b:
		if j % 2 == 0:
			maxthis += j
	if maxthis > maxeven:
		maxeven = maxthis
print(maxeven)


def transform(xx, i):
	x = xx[:]
	(p, q) = divmod(x[i], 14)
	x[i] = 0
	for k in range(14):
		x[k] += p
	for k in range(q):
		x[(k + i + 1) % 14] += 1
	return sum(filter(lambda z: not z & 1, x))
n = list(map(int, input().split()))
print(max((transform(n, k) for k in range(14))))


a = [int(x) for x in input().split()]
max_score = int(0)
for i in range(14):
	b = list(a)
	b[i] = 0
	x = a[i]
	for j in range(14):
		index = (i + j + 1) % 14
		summand = x // 14
		if x % 14 != 0 and x % 14 > j:
			summand = summand + 1
		b[index] = b[index] + summand
	score = 0
	for j in range(14):
		if b[j] % 2 == 0:
			score = score + int(b[j])
	max_score = max(max_score, score)
print('{}'.format(max_score))


list1 = list(map(int, input().split()))
sum1 = 0
for i in range(len(list1)):
	s = int(list1[i] / 14)
	mod = list1[i] % 14
	tempS = 0
	if s % 2 == 0:
		tempS += s
	for j in range(1, len(list1)):
		if (list1[(i + j) % 14] + (mod > 0) + s) % 2 == 0:
			tempS += list1[(i + j) % 14] + (mod > 0) + s
		mod -= 1
	sum1 = max(sum1, tempS)
print(sum1)


l = list(map(int, input().split()))
ms = 0
for i in range(14):
	if l[i] > 0:
		d = l[i] // 14
		o = l[i] % 14
		nl = [l[k] for k in range(len(l))]
		nl[i] = 0
		for j in range(len(l)):
			nl[j] += d
		j = i + 1
		j %= 14
		for vbn in range(o):
			nl[j] += 1
			j += 1
			j %= 14
		s = 0
		for m in range(len(l)):
			if nl[m] % 2 == 0:
				s += nl[m]
		ms = max(ms, s)
print(ms)


a = list(map(int, input().split()))
res = 0
for i in range(14):
	if a[i] > 0:
		x = a[i] // 14
		x1 = a[i] % 14
		b = a[:]
		b[i] = 0
		for j in range(14):
			b[j] += x
		if x1 >= 1:
			for j in range(1, x1 + 1):
				b[(i + j) % 14] += 1
		y = 0
		for k in b:
			if k % 2 == 0:
				y += k
		res = max(res, y)
print(res)


d = list(map(int, input().split()))

def play(d, i):
	stones = d[i]
	d[i] = 0
	add = int(stones / 14)
	addParity = add % 2
	stones = stones % 14
	while stones:
		stones -= 1
		i += 1
		d[i % 14] += 1
	s = 0
	for value in d:
		if value % 2 == addParity:
			s += value + add
	return s
m = 0
for i in range(len(d)):
	if d[i]:
		m = max(m, play(list(d), i))
print(m)


def point_sum(st):
	s = 0
	for i in range(14):
		if st[i] % 2 == 0:
			s += st[i]
	return s

def step(st, i):
	a = st.copy()
	element = a[i]
	a[i] = 0
	(q, w) = divmod(element, 14)
	for z in range(14):
		point = (z + i + 1) % 14
		a[point] += q
		if z < w:
			a[point] += 1
	return point_sum(a)
st = list(map(int, input().split()))
results = []
for i in range(14):
	if st[i] == 0:
		results.append(point_sum(st))
	else:
		results.append(step(st, i))
print(max(results))


mx = 0
s = list(map(int, input().split()))
for i in range(14):
	if s[i] > 0:
		res = 0
		sw = list(s)
		x = sw[i]
		sw[i] = 0
		if x < 14 - i - 1:
			for j in range(i + 1, i + x + 1):
				sw[j] += 1
		else:
			x -= 14 - i - 1
			for j in range(i + 1, 14):
				sw[j] += 1
			t = x // 14
			ost = x % 14
			for j in range(14):
				if j < ost:
					sw[j] += t + 1
				else:
					sw[j] += t
		for x in sw:
			if x % 2 == 0:
				res += x
		if res >= mx:
			mx = res
print(mx)


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())

def solve(i):
	tot_stone = a[i]
	same_dist = tot_stone // 14
	res_dist = tot_stone % 14
	ans = 0
	aa = a[:]
	aa[i] = 0
	for ii in range(14):
		aa[ii] += same_dist
	for ii in range(i + 1, i + 1 + res_dist):
		aa[ii % 14] += 1
	for ii in range(14):
		if aa[ii] % 2 == 0:
			ans += aa[ii]
	return ans
a = list(rint())
max_ans = 0
for i in range(14):
	s = solve(i)
	max_ans = max(s, max_ans)
print(max_ans)


arr = list(map(int, input().split()))
m = 0
for i in range(14):
	x = arr[i] // 14
	y = arr[i] % 14
	t = [j + x for j in arr]
	t[i] = x
	for k in range(y):
		t[(i + k + 1) % 14] += 1
	s = sum((num for num in t if num % 2 == 0))
	m = max(s, m)
print(m)


l1 = list(map(int, input().split()))
l = []
m = len(l1)
for i in range(m):
	a = 0
	l2 = l1.copy()
	l2[i] = 0
	n1 = l1[i] // m
	n2 = l1[i] % m
	for j in range(1, m + 1):
		l2[(i + j) % m] += n1
	for j in range(1, n2 + 1):
		l2[(i + j) % m] += 1
	for j in range(m):
		if l2[j] % 2 == 0:
			a += l2[j]
	l.append(a)
print(max(l))


def findScore(board, num):
	stones = board[num]
	div = int(stones / 14)
	mod = int(stones % 14)
	board[num] = 0
	for i in range(len(board)):
		if i < mod:
			board[int((num + i + 1) % 14)] += div + 1
		else:
			board[int((num + i + 1) % 14)] += div
	score = 0
	for i in board:
		if i % 2 == 0:
			score += i
	return score
board1 = input().split(' ')
board = []
for i in board1:
	board.append(int(i))
maxScore = 0
for i in range(len(board)):
	if board[i] > 0:
		maxScore = max(maxScore, findScore(board[:], i))
print(maxScore)


ans = 0
board = [int(x) for x in input().split()]
for i in range(14):
	tmp = [x for x in board]
	tmp2 = tmp[i]
	tmp[i] = 0
	for j in range(14):
		tmp[j] += tmp2 // 14
	tmp2 %= 14
	for j in range(1, tmp2 + 1):
		tmp[(i + j) % 14] += 1
	ans = max(ans, sum([x for x in tmp if x % 2 == 0]))
print(ans)


a = list(map(int, input().split()))
m = 0
for i in range(14):
	b = a[:]
	b[i] = 0
	s = a[i]
	f = s // 14
	for j in range(14):
		b[j] += f
	for j in range(1, s % 14 + 1):
		b[(i + j) % 14] += 1
	sc = 0
	for j in b:
		if j % 2 == 0:
			sc += j
	m = max(m, sc)
print(m)


from sys import stdin, stdout
arr = [int(x) for x in stdin.readline().split()]
sum = 0
for x in range(len(arr)):
	if not arr[x]:
		continue
	a = arr[x] // 14
	s = arr[x] % 14
	ssum = a if a % 2 == 0 else 0
	for i in range(1, 14):
		val = arr[(x + i) % 14] + (1 if s > 0 else 0) + a
		ssum += val if not val % 2 else 0
		s -= 1
	sum = max(sum, ssum)
print(sum)


a = list(map(int, input().split()))
mx = 0
for i in range(14):
	x = a.copy()
	n = x[i]
	x[i] = 0
	for j in range(i + 1, 14):
		x[j] += 1
		n -= 1
	p = n // 14
	for j in range(14):
		x[j] += p
	p = n % 14
	z = 0
	while p > 0:
		x[z] += 1
		p -= 1
		z += 1
	s = 0
	for j in range(14):
		if x[j] & 1 == 0:
			s += x[j]
	mx = max(mx, s)
print(mx)


l = list(map(int, input().split()))
c = 0
for i in range(14):
	k = 0
	m = [t for t in l]
	for j in range(14):
		if j > i and m[i] >= j - i and ((m[j] + 1 + (m[i] - j + i) // 14) % 2 == 0):
			k += m[j] + 1 + (m[i] - j + i) // 14
		elif j < i and m[i] >= 14 - i + j and ((m[j] + 1 + (m[i] - 14 + i - j) // 14) % 2 == 0):
			k += m[j] + 1 + (m[i] - 14 + i - j) // 14
		elif j == i:
			if m[i] // 14 % 2 == 0:
				k += m[i] // 14
	if k > c:
		c = k
print(c)


l = [*map(int, input().split())]
n = len(l)
res = 0
for i in range(n):
	if l[i] == 0:
		continue
	tmp = l[:]
	tmp[i] = 0
	x = l[i]
	for j in range(n):
		k = (i + 1 + j) % n
		tmp[k] += x // n
		if j < x % n:
			tmp[k] += 1
	ans = sum((e for e in tmp if e & 1 == 0))
	res = max(res, ans)
print(res)


a = []
for s in input().split():
	a.append(int(s))
maxscore = 0
for i in range(14):
	tmp = a[:]
	t = tmp[i]
	tmp[i] = 0
	for j in range(14):
		tmp[j] += t // 14
	for j in range(t % 14):
		tmp[(i + j + 1) % 14] += 1
	total = sum([k for k in tmp if k % 2 == 0])
	maxscore = max(maxscore, total)
print(maxscore)


n = 14
a = [int(v) for v in input().split()]
assert len(a) == n
ans = 0
for i in range(n):
	if a[i] == 0:
		continue
	(q, r) = divmod(a[i], n)
	curr = 0
	for j in range(n):
		val = (a[(i + j) % n] if j != 0 else 0) + q + (1 if 1 <= j <= r else 0)
		if val % 2 == 0:
			curr += val
	ans = max(ans, curr)
print(ans)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections, re, itertools, statistics, math
from collections import *
from itertools import *
from statistics import *
from math import *
from re import *
mod = int(1000000000.0 + 7)
imin = -2147483648
imax = 2147483647
true = True
false = False
none = None
inp = lambda : input()
I = lambda : int(inp())
M = lambda : map(int, inp().split())
L = lambda : list(M())
Yes = lambda : print('Yes')
No = lambda : print('No')
YES = lambda : print('YES')
NO = lambda : print('NO')

def IO():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def true_yes(statement):
	return YES() if statement else NO()

def state(statement, one, two):
	print(one if statement else two)

def swap(a, b):
	(a, b) = (b, a)

def prec(a):
	return '{0:.7f}'.format(a)

def binary_search(arr, low, high, x):
	while low <= high:
		mid = low + (high - low) // 2
		if arr[mid] == x:
			return [mid, true]
		elif arr[mid] > x:
			high = mid - 1
		else:
			low = mid - 1
	return [-1, false]

def kabraji_ka_totka():
	a = L()

	def score(i):
		b = a[i + 1:] + a[0:i] + [0]
		for j in range(14):
			b[j] += a[i] // 14
		for j in range(a[i] % 14):
			b[j] += 1
		return sum((x for x in b if x % 2 == 0))
	print(max((score(i) for i in range(14))))
kabraji_ka_totka()


ans = 0
n = [*map(int, input().split())]
for i in range(14):
	x = n[:]
	t = x[i]
	x[i] = 0
	loop = t // 14
	tempAns = 0
	for j in range(14):
		x[j] += loop
	for j in range(1, t % 14 + 1):
		x[(i + j) % 14] += 1
	for i in x:
		if i % 2 == 0:
			tempAns += i
	ans = max(ans, tempAns)
print(ans)


from sys import stdin, stdout
from math import factorial
from math import log10
n = 14
challengers = list(map(int, stdin.readline().split()))
ans = 0
for i in range(n):
	if not challengers[i]:
		continue
	test = challengers[:]
	cnt = test[i]
	test[i] = 0
	for j in range(i + 1, n):
		test[j] += 1
		cnt -= 1
		if cnt == 0:
			break
	value = cnt // 14
	for j in range(n):
		test[j] += value
		cnt -= value
	for j in range(cnt % 14):
		test[j] += 1
	cur_ans = 0
	for z in range(n):
		if not test[z] & 1:
			cur_ans += test[z]
	ans = max(ans, cur_ans)
stdout.write(str(ans))


a = list(map(int, input().split()))
result = 0
for i in range(14):
	b = a[:]
	b[i] = 0
	for j in range(i + 1, i + 15):
		b[j % 14] += a[i] // 14
	for j in range(i + 1, i + 1 + a[i] % 14):
		b[j % 14] += 1
	result = max(result, sum([x for x in b if x % 2 == 0]))
print(result)


(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, dgraphs, mod) = (lambda : sorted(zz()), {}, 10 ** 9 + 7)
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
l = zz()
ans = -1
for (i, j) in enumerate(l):
	p = l[:]
	p[i] = 0
	n = j // 14
	ex = j % 14
	m = i + 1
	for _ in range(ex):
		if m == 14:
			m = 0
			p[m] = p[m] + 1
			m += 1
		else:
			p[m] = p[m] + 1
			m += 1
	for k in range(14):
		p[k] = p[k] + n
	t = 0
	for i in p:
		if i % 2 == 0:
			t += i
	if t > ans:
		ans = t
print(ans)


b = list(map(int, input().split()))
n = 14
ans = 0
for i in range(n):
	a = b.copy()
	if a[i] == 0:
		continue
	x = a[i]
	a[i] = 0
	full = x // n
	xex = x % n
	for j in range(n):
		a[j] += full
	for j in range(xex):
		a[(i + j + 1) % n] += 1
	pot = 0
	for j in a:
		if j % 2 == 0:
			pot += j
	ans = max(ans, pot)
print(ans)


a = list(map(int, input().split()))
maxi = -1
for i in range(14):
	s = 0
	if a[i] != 0:
		cel = a[i] // 14
		ost = a[i] % 14
		for ty in range(1, 14):
			if i + ty > 13:
				i -= 14
			su = a[i + ty] + cel
			if ty <= ost:
				su += 1
			if su % 2 == 0:
				s += su
		if cel % 2 == 0:
			s += cel
	if s > maxi:
		maxi = s
print(maxi)


s = [int(x) for x in input().split()]
maxi = 0
for x in range(14):
	if s[x] != 0:
		c = s.copy()
		c[x] = 0
		const = s[x] // 14
		ost = s[x] % 14
		for i in range(14):
			c[i] += const
		for i in range(x + 1, x + ost + 1):
			c[i % 14] += 1
		ans = 0
		for i in range(14):
			if c[i] % 2 == 0:
				ans += c[i]
		maxi = max(maxi, ans)
print(maxi)


from bisect import bisect_left, bisect_right

def tuple_input(type):
	return map(type, input().strip().split())

def print_list(s):
	print(''.join(map(str, s)))
a = list(tuple_input(int))
res = 0
for i in range(len(a)):
	b = list(a)
	d = b[i] // 14
	r = b[i] % 14
	b[i] = 0
	for j in range(len(b)):
		b[j] += d
	p = (i + 1) % 14
	for _ in range(r):
		b[p] += 1
		p = (p + 1) % 14
	tot = 0
	for j in range(len(b)):
		if b[j] % 2 == 0:
			tot += b[j]
	res = max(res, tot)
print(res)


b = list(map(int, input().split()))
ans = 0
for i in range(14):
	a = []
	for k in range(14):
		a.append(b[k])
	count = a[i]
	a[i] = 0
	h = count % 14
	h1 = count // 14
	for j in range(i + 1, i + 1 + 14):
		if j < i + 1 + h:
			j %= 14
			a[j] += h1 + 1
		else:
			j %= 14
			a[j] += h1
	n_ans = 0
	for k in range(14):
		if a[k] % 2 == 0:
			n_ans += a[k]
	ans = max(ans, n_ans)
print(ans)


arr = list(map(int, input().split()))
ans = 0
for i in range(len(arr)):
	pol = arr[i] // 14
	os = arr[i] % 14
	cur = 0
	if pol % 2 == 0:
		cur += pol
	j = i + 1
	if j == 14:
		j = 0
	for u in range(13):
		num = 0
		if u < os:
			num += 1
		num += arr[j] + pol
		if num % 2 == 0:
			cur += num
		j = j + 1
		if j == 14:
			j = 0
	if cur > ans:
		ans = cur
print(ans)


a = list(map(int, input().split()))
n = 14
m = 0
for i in range(n):
	b = a[:]
	(x, b[i]) = (b[i], 0)
	for j in range(n):
		b[j] += x // n
	x %= n
	while x:
		i = (i + 1) % n
		b[i] += 1
		x -= 1
	m = max(m, sum((x for x in b if x & 1 < 1)))
print(m)


class CodeforcesTask975BSolution:

	def __init__(self):
		self.result = ''
		self.mancala = []

	def read_input(self):
		self.mancala = [int(x) for x in input().split(' ')]

	def process_task(self):
		mx = 0
		for move in range(14):
			taken = self.mancala[move]
			n_board = self.mancala[:]
			n_board[move] = 0
			adding = taken // 14
			n_board = [x + adding for x in n_board]
			taken = taken % 14
			move += 1
			move = move % 14
			while taken:
				n_board[move] += 1
				taken -= 1
				move += 1
				move = move % 14
			mx = max(mx, sum([x for x in n_board if not x % 2]))
		self.result = str(mx)

	def get_result(self):
		return self.result
Solution = CodeforcesTask975BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


A = list(map(int, input().split()))
ans = 0
for i in range(14):
	if A[i] == 0:
		continue
	B = A + A
	B[i + 14] = 0
	(q, r) = divmod(B[i], 14)
	for j in range(1, 15):
		if j <= r:
			B[i + j] += q + 1
		else:
			B[i + j] += q
	temp = 0
	for j in range(i + 1, i + 15):
		if B[j] % 2 == 0:
			temp += B[j]
	ans = max(ans, temp)
print(ans)


list1 = [int(x) for x in input().split()]
max_value = 0
for x in range(14):
	if list1[x] != 0:
		list2 = list1[:]
		for i in range(14):
			list2[i] += list1[x] // 14
		j = x + 1
		for i in range(list1[x] % 14):
			j %= 14
			list2[j] += 1
			j += 1
		sum1 = 0
		list2[x] -= list1[x]
		for i in range(14):
			if list2[i] % 2 == 0:
				sum1 += list2[i]
		max_value = max(max_value, sum1)
print(max_value)


a = list(map(int, input().split()))
c = []
sum = 0
for i in range(14):
	b = a[:]
	sum = 0
	for j in range(14):
		if j < a[i] % 14 and j != 13:
			b[(i + j + 1) % 14] += a[i] // 14 + 1
		elif j == 13:
			b[(i + j + 1) % 14] = a[i] // 14
		elif j >= a[i] % 14 and j != 13:
			b[(i + j + 1) % 14] += a[i] // 14
		else:
			b[(i + j + 1) % 14] = a[i] // 14
		if b[(i + j + 1) % 14] % 2 == 0:
			sum += b[(i + j + 1) % 14]
	c.append(sum)
print(max(c))


a = list(map(int, input().split()))

def auxiliary(l):
	return sum((x * (x % 2 == 0) for x in l))
result = 0
for i in range(14):
	temp = a[:]
	for j in range(13):
		temp[(i + j + 1) % 14] += temp[i] // 14 + (1 if j + 1 <= temp[i] % 14 else 0)
	temp[i] = temp[i] // 14
	result = max(result, auxiliary(temp))
print(result)


a = list(map(int, input().split()))
b = list()
for i in range(14):
	b.append(0)
ans = 0
ii = 0
for i in range(14):
	if a[i] > 0:
		for j in range(14):
			b[j] = a[j]
		tmp = b[i]
		cnt = b[i] // 14
		tmp = b[i] % 14
		b[i] = 0
		for j in range(14):
			b[j] = b[j] + cnt
		flag = (i + 1) % 14
		while tmp > 0:
			b[flag] = b[flag] + 1
			tmp = tmp - 1
			flag = (flag + 1) % 14
		res = 0
		for j in range(14):
			if b[j] % 2 == 0:
				res = res + b[j]
		ans = max(ans, res)
print(ans)


nl = [int(i) for i in input().split()]
ms = int(0)
for i in range(14):
	if nl[i] > 0:
		nlt = nl.copy()
		nt = nlt[i]
		nlt[i] = 0
		for j in range(14):
			if j <= i:
				nlt[j] += (nt + i - j) // 14
			else:
				nlt[j] += (nt + i - j) // 14 + 1
		s = int(0)
		for k in range(14):
			if nlt[k] % 2 == 0:
				s += nlt[k]
		ms = max(ms, s)
print(ms)


b = list(map(int, input().split()))
pans = 0
for i in range(14):
	a = b.copy()
	if a[i] == 0:
		continue
	k = a[i]
	a[i] = 0
	for j in range(i + 1, 14):
		k -= 1
		a[j] += 1
	for j in range(14):
		a[j] += k // 14
	k %= 14
	for j in range(k):
		a[j] += 1
	ans = 0
	for j in range(14):
		if a[j] % 2 == 0:
			ans += a[j]
	if ans > pans:
		pans = ans
print(pans)


l = list(map(int, input().split()))
n = 0
m = -1
while n < 14:
	c = 0
	g = l.copy()
	div = l[n] // 14
	h = l[n] % 14
	i = n + 1
	sum = div * 14
	g[n] = 0
	while sum:
		if i == 14:
			i = 0
		g[i] += div
		sum -= div
		i += 1
	i = n + 1
	while h:
		if i == 14:
			i = 0
		g[i] += 1
		h -= 1
		i += 1
	for j in g:
		if j % 2 == 0:
			c += j
	m = max(c, m)
	n += 1
print(m)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

def nninp():
	return map(int, input().split())

def llinp():
	return list(map(int, input().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
from collections import OrderedDict
a = llinp()
ans = 0
for i in range(14):
	temp = a.copy()
	nos = temp[i]
	temp[i] = 0
	for j in range(i + 1, 14):
		temp[j] += 1
		nos -= 1
	for j in range(0, 14):
		temp[j] += nos // 14
	nos = nos % 14
	j = 0
	while nos != 0:
		temp[j] += 1
		nos -= 1
		j += 1
	ans1 = 0
	for c in temp:
		if c % 2 == 0:
			ans1 += c
	ans = max(ans, ans1)
p(ans)


l = list(map(int, input().split()))
ans = 0
for i in range(14):
	a = []
	m = 0
	a.extend(l)
	c = a[i] // 14
	d = a[i] % 14
	a[i] = 0
	j = 1
	while j <= d:
		k = (i + j) % 14
		a[k] += 1
		j += 1
	for j in range(14):
		a[j] += c
		if a[j] % 2 == 0:
			m += a[j]
	ans = max(ans, m)
print(ans)


A = list(map(int, input().split()))
maxi = 0
for i in range(0, 14):
	B = []
	B = A.copy()
	summ = 0
	if B[i] > 0:
		if 13 - i >= B[i]:
			for j in range(i + 1, i + 1 + B[i]):
				B[j] += 1
		else:
			for j in range(i + 1, 14):
				B[j] += 1
				B[i] -= 1
			x = B[i] // 14
			r = B[i] % 14
			B[i] = 0
			if x > 0:
				for j in range(0, 14):
					B[j] += x
			for j in range(0, r):
				B[j] += 1
		for j in range(0, 14):
			if B[j] % 2 == 0:
				summ += B[j]
	if summ > maxi:
		maxi = summ
print(maxi)


def go():
	data = [int(i) for i in input().split(' ')]
	n = len(data)
	good = 0
	for i in range(n):
		if data[i] == 0:
			continue
		add_each = data[i] // 14
		left = data[i] % 14
		current_data = data[i + 1:] + data[:i + 1]
		current_data[-1] = 0
		current_good = 0
		for j in range(n):
			val = add_each + current_data[j]
			if left > j:
				val += 1
			if val % 2 == 0:
				current_good += val
		if current_good > good:
			good = current_good
	print(good)
go()


a = list(map(int, input().split(' ')))
result = 0
dim = len(a)
for i in range(dim):
	b = a.copy()
	n = b[i]
	b[i] = 0
	for j in range(1, dim + 1):
		k = i + j
		if k >= dim:
			k -= dim
		count = (n + (dim - j)) // dim
		b[k] += count
	currResult = 0
	for j in range(dim):
		if b[j] % 2 == 0:
			currResult += b[j]
	result = max(result, currResult)
print(result)


from copy import deepcopy
a = list(map(int, input().split()))
ans = 0
for i in range(14):
	if not a[i]:
		continue
	b = deepcopy(a)
	(div, mod) = divmod(b[i], 14)
	b[i] = 0
	for j in range(i + 1, i + 1 + mod):
		b[j % 14] += 1
	b = [x + div for x in b]
	ans = max(ans, sum([x for x in b if x % 2 == 0]))
print(ans)


a = list(map(int, input().split()))
v = []
maxa = -1
for i in range(14):
	sm = 0
	if a[i] % 2 != 0:
		q = a[i] // 14
		r = a[i] % 14
		v = []
		for k in a:
			v.append(k)
		p = v[i]
		v[i] = 0
		for j in range(0, len(v)):
			v[j] += q
		if r <= 13 - i:
			j = i + 1
			while r != 0:
				v[j] += 1
				r -= 1
				j += 1
		else:
			b = r - (13 - i)
			for j in range(i + 1, 14):
				v[j] += 1
			for j in range(b):
				v[j] += 1
		for j in v:
			if j % 2 == 0:
				sm += j
	if sm > maxa:
		maxa = sm
print(maxa)


A = [int(x) for x in input().split()]
N = 14
result = 0
for i in range(N):
	B = A[:]
	to_distribute = B[i]
	B[i] = 0
	for j in range(N):
		B[j] += to_distribute // N
	for j in range(1, to_distribute % N + 1):
		B[(i + j) % N] += 1
	result = max(result, sum([x for x in B if x % 2 == 0]))
print(result)


lst = list(map(int, input().strip().split(' ')))
m = 0
for i in range(14):
	l = []
	l = lst[:]
	x = l[i]
	x1 = x // 14
	y = x % 14
	l[i] = 0
	for j in range(14):
		l[j] += x1
	t = i
	while y != 0:
		if t < 13:
			t += 1
			l[t] += 1
			y -= 1
		elif t == 13:
			t = 0
			l[t] += 1
			y -= 1
	s = 0
	for j in range(14):
		if l[j] % 2 == 0:
			s += l[j]
	if s > m:
		m = s
print(m)


a = [int(s) for s in input().split()]
maxscore = 0
for i in range(len(a)):
	aa = list(a)
	aa[i] = 0
	if a[i] >= 14:
		aa = [aai + a[i] // 14 for aai in aa]
	for j in range(i + 1, i + 1 + a[i] % 14):
		aa[j % 14] += 1
	score = 0
	for aai in aa:
		if aai % 2 == 0:
			score += aai
	if score > maxscore:
		maxscore = score
print(maxscore)


from math import ceil
(X, Answer) = (list(map(int, input().split())), [])
Check = [i for i in range(14) if X[i] != 0]
for i in Check:
	(Temp, Stone) = (X[:], X[i])
	Temp[i] = 0
	(Sum, Num) = (0, 14)
	index = (i + 1) % 14
	while Stone != 0:
		SumTemp = ceil(Stone / Num)
		Temp[index] += SumTemp
		Stone -= SumTemp
		Sum += Temp[index] if Temp[index] % 2 == 0 else 0
		index = (index + 1) % 14
		Num -= 1
	Answer.append(Sum)
print(max(Answer))


import copy

def evens(arr):
	res = 0
	for num in arr:
		if num % 2 == 0:
			res += num
	return res

def move(arr, i, n):
	curr = arr[i]
	if curr < n:
		arr[i] = 0
		for j in range(1, curr + 1):
			arr[(i + j) % n] += 1
	else:
		numInc = curr // n
		arr[i] = curr % n
		for j in range(1, arr[i] + 1):
			arr[(i + j) % n] += 1
		arr[i] = 0
		for j in range(n):
			arr[j] += numInc
	return evens(arr)
arr = list(map(int, input().split()))
n = len(arr)
ans = 0
for i in range(n):
	arr2 = copy.copy(arr)
	res = move(arr2, i, n)
	ans = max(ans, res)
print(ans)


l = list(map(int, input().split()))
m = list(l)
ans = 0
max = 0
for i in range(0, 14):
	if l[i] > 0:
		x = l[i]
		l[i] = 0
		y = int(x / 14)
		z = x % 14
		for j in range(14):
			l[j] = l[j] + y
		for k in range(1, z + 1):
			l[(i + k) % 14] = l[(i + k) % 14] + 1
		for o in range(14):
			if l[o] % 2 == 0:
				max = max + l[o]
		l = list(m)
		if max > ans:
			ans = max
		max = 0
print(ans)


a = list(map(int, input().split()))
mr = 0
for t in range(14):
	b = list(a)
	m = b[t]
	k = t
	i = 1
	b[k] = 0
	while m > 0:
		if m // 14 == 0:
			b[(k + i) % 14] += 1
			m -= 1
			i += 1
		else:
			q = m // 14
			for c in range(14):
				b[c] += q
			m -= 14 * q
	p = sum([x for x in b if x % 2 == 0])
	mr = max(p, mr)
print(mr)


i = list(map(int, input().split()))
m = 0
for (index, element) in enumerate(i):
	n = i.copy()
	n[index] = 0
	d = element // 14
	r = element % 14
	n = [x + d for x in n]
	n[index + 1:index + 1 + r] = [x + 1 for x in n[index + 1:index + 1 + r]]
	if index + r + 1 >= 14:
		n[:index + r + 1 - 14] = [x + 1 for x in n[:index + r + 1 - 14]]
	s = sum([x for x in n if x % 2 == 0])
	m = max(m, s)
print(m)


from copy import deepcopy

def score(A, i):
	ret = 0
	B = deepcopy(A)
	if A[i] == 0:
		return 0
	elif A[i] <= 13 - i:
		B[i] = 0
		for j in range(i + 1, i + A[i] + 1):
			B[j] += 1
		for j in range(14):
			if B[j] % 2 == 0:
				ret += B[j]
		return ret
	else:
		B[i] = 0
		for j in range(i + 1, 14):
			B[j] += 1
		res = A[i] - (13 - i)
		que = res // 14
		div = res % 14
		for j in range(14):
			if j < div:
				B[j] += que + 1
			else:
				B[j] += que
		for j in range(14):
			if B[j] % 2 == 0:
				ret += B[j]
		return ret
A = list(map(int, input().split()))
point = [score(A, i) for i in range(14)]
print(max(point))


ai = list(map(int, input().split()))
i = 0
ans = 0
while i < 14:
	j = 0
	ai2 = [0] * 14
	while j < 14:
		ai2[j] = ai[j]
		j += 1
	j = 0
	temp = ai2[i]
	temp2 = temp % 14
	temp3 = temp // 14
	ai2[i] = 0
	tempans = 0
	while j < 14:
		ai2[j] += temp3
		j += 1
	j = (i + 1) % 14
	while temp2 > 0:
		ai2[j] += 1
		temp2 -= 1
		j = (j + 1) % 14
	j = 0
	while j < 14:
		if ai2[j] % 2 == 0:
			tempans += ai2[j]
		j += 1
	ans = max(ans, tempans)
	i += 1
print(ans)


a = list(map(int, input().split()))
answer = 0
for i in range(14):
	if a[i] != 0:
		k = a[i] // 14
		m = a[i] % 14
		attempt = 0
		for j in range(14):
			if i != j:
				test = a[j] + k + ((j - i + 14) % 14 <= m)
			else:
				test = k
			if test % 2 == 0:
				attempt += test
		if attempt > answer:
			answer = attempt
print(answer)


N = 14

def possible_max(arr, pos):
	val = arr[pos]
	int_part = val // N
	float_part = val % N
	count = 0
	for (i, el) in enumerate(arr):
		tmp = el + int_part
		if i == pos:
			tmp -= val
		if pos < i and i <= pos + float_part:
			tmp += 1
		if pos + float_part >= N and i <= (pos + float_part) % N:
			tmp += 1
		if tmp % 2 == 0:
			count += tmp
	return count
line = input()
arr = list(map(int, line.split()))
count = 0
for (i, el) in enumerate(arr):
	if el % 2 == 0:
		count += el
max_val = 0
for i in range(N):
	if arr[i] == 0:
		cur_val = count
	else:
		cur_val = possible_max(arr, i)
	if cur_val > max_val:
		max_val = cur_val
print(max_val)


def f(a, ind):
	if a[ind] == 0:
		return -1
	k = a[ind] // 14
	x = a[ind] % 14
	b = a[:]
	b[ind] = 0
	for j in range(14):
		b[j] += k
	for j in range(ind + 1, ind + x + 1):
		j1 = j % 14
		b[j1] += 1
	res = 0
	for j in range(14):
		if b[j] % 2 == 0:
			res += b[j]
	return res
a = list(map(int, input().split()))
ans = 0
for i in range(14):
	cur = f(a, i)
	ans = max(ans, cur)
print(ans)


from copy import copy
qaq = 0
A = list(map(int, input().split()))
for z in range(14):
	if A[z] != 0:
		K = copy(A)
		K[z] = 0
		for t in range(len(K)):
			K[t] += A[z] // 14
		for u in range(z + 1, z + 1 + A[z] % 14):
			u %= 14
			K[u] += 1
		cnt = 0
		for t in K:
			if t % 2 == 0:
				cnt += t
		qaq = max(qaq, cnt)
print(qaq)


arr = list(map(int, input().split()))
res = 0
for i in range(14):
	temp_arr = arr.copy()
	current = temp_arr[i]
	temp_arr[i] = 0
	d = current // 14
	mod = current % 14
	for t_ in range(14):
		temp_arr[t_] += d
	for t in range(1, mod + 1):
		temp_arr[(t + i) % 14] += 1
	count = 0
	for ta in temp_arr:
		if ta % 2 == 0:
			count += ta
	res = max(res, count)
print(res)


l = list(map(int, input().split()))
m = l * 2
anss = 0
for j in range(14):
	som = 0
	if l[j] != 0:
		a = m[j]
		x = m[j] % 14
		y = m[j] // 14
		m[j] = 0
		m[j + 14] = 0
		for i in range(1, 15, 1):
			if i <= x:
				if (m[j + i] + 1 + y) % 2 == 0:
					som += m[j + i] + 1 + y
			elif (m[j + i] + y) % 2 == 0:
				som += m[j + i] + y
		m[j] = a
		m[j + 14] = a
		anss = max(anss, som)
print(anss)


a = list(map(int, input().split()))
n = 14
f = lambda a: sum((x for x in a if x & 1 ^ 1))

def g(a, x):
	b = a[:]
	y = a[x]
	b[x] = 0
	for i in range(n):
		b[i] += y // n
	y %= n
	for i in range(x + 1, y + x + 1):
		b[i % 14] += 1
	return f(b)
print(max((g(a, i) for i in range(n))))


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def f(a, i):
	t = a[i]
	a[i] = 0
	for j in range(14):
		a[j] += t // 14
	for j in range(t % 14):
		a[(i + j + 1) % 14] += 1
	return sum((x for x in a if x % 2 == 0))

def main():
	a = [int(x) for x in input().split()]
	scr = 0
	for i in range(14):
		aa = a[:]
		scr = max(scr, f(aa, i))
	print(scr)
main()


def score(arr, i):
	if arr[i] == 0:
		return 0
	m = arr[i]
	q = m // 14
	r = m - 14 * q
	arr = [item + q for item in arr]
	for k in range(1, r + 1):
		arr[(i + k) % 14] += 1
	arr[i] -= m
	return sum([item for item in arr if item % 2 == 0])
arr = [int(x) for x in input().split()]
print(max([score(arr, i) for i in range(14)]))


a = [int(i) for i in input().split()]
mx = -1
for i in range(14):
	b = a.copy()
	if a[i]:
		(b[i], d, ans) = (0, i + 1, 0)
		r = (a[i] + d) // 14
		l = (a[i] + d) % 14
		if d + a[i] < 14:
			ans = sum([j + 1 for j in a[d:d + a[i]] if not (j + 1) % 2])
		else:
			for j in range(14):
				b[j] += r
			if d > l:
				for j in range(l, d):
					b[j] -= 1
			else:
				for j in range(d, d + abs(d - l)):
					b[j] += 1
			ans = sum([p for p in b if not p % 2])
		mx = max(mx, ans)
print(mx)


def sumeven(arr):
	sum1 = 0
	for x in arr:
		if x % 2 == 0:
			sum1 += x
	return sum1
a = list(map(int, input().strip().split()))
a1 = [i[0] for i in sorted(enumerate(a), key=lambda x: x[1])]
a1.reverse()
max1 = 0
for i in a1:
	if a[i] > 0:
		b = list(a)
		b[i] = 0
		index = i + 1
		if a[i] > 14:
			s = a[i] // 14
			if s > 0:
				b = list(map(lambda x: x + s, b))
		for x in range(a[i] % 14):
			if index > 13:
				index = 0
			b[index] = b[index] + 1
			index += 1
		max1 = max(max1, sumeven(b))
print(max1)


import copy
stones = list(map(int, input().split()))
s = 0
for i in range(14):
	case = copy.deepcopy(stones)
	ca = stones[i]
	s1 = 0
	case[i] = 0
	for j in range(14):
		case[j] += ca // 14
	for j in range(ca % 14):
		case[(i + j + 1) % 14] += 1
	s1 = sum([k for k in case if k % 2 == 0])
	s = max(s1, s)
print(s)


a = list(map(int, input().split()))
ans = 0
for i in range(14):
	(x, b, tru, dop) = (a[i], a[:], a[i] // 14, a[i] % 14)
	b[i] = 0
	for j in range(i + 1, 14):
		b[j] += tru
		if dop > 0:
			b[j] += 1
			dop -= 1
	for j in range(0, i + 1):
		b[j] += tru
		if dop > 0:
			b[j] += 1
			dop -= 1
	cnt = 0
	for j in range(14):
		cnt += b[j] if b[j] % 2 == 0 else 0
	ans = max(ans, cnt)
print(ans)


l = list(map(int, input().split()))
s = []
for i in l:
	s.append(i)
m = 0
for i in range(14):
	if l[i] > 0:
		c = 0
		x = l[i] % 14
		y = l[i] // 14
		d = s
		d[i] = 0
		for j in range(1, x + 1):
			d[(i + j) % 14] += 1
		for j in range(14):
			d[j] += y
		for j in range(14):
			if d[j] % 2 == 0:
				c += d[j]
		m = max(c, m)
		s = []
		for i in l:
			s.append(i)
print(m)


stones = list(map(int, input().split()))

def move(i):
	t = list(tuple(stones))
	score = 0
	tot = t[i] % 14
	r = t[i] // 14
	cntr = i
	t[i] = 0
	while tot > 0:
		cntr += 1
		cntr %= 14
		t[cntr] += 1
		tot -= 1
	for i in range(len(t)):
		t[i] += r
	for num in t:
		if num % 2 == 0:
			score += num
	return score
maxsc = 0
for i in range(len(stones)):
	if stones[i] > 0:
		maxsc = max(maxsc, move(i))
print(maxsc)


a = list(map(int, input().split()))
ans = 0
for i in range(14):
	if a[i] == 0:
		continue
	b = [a[j] for j in range(14)]
	b[i] = 0
	for j in range(14):
		b[(i + j + 1) % 14] += a[i] // 14
		if j < a[i] % 14:
			b[(i + j + 1) % 14] += 1
	ans = max(ans, sum(filter(lambda x: x if x % 2 == 0 else 0, b)))
print(ans)


def get_score(pos, pos___stones_nr):
	if pos___stones_nr[pos] <= 0:
		return -1
	div = pos___stones_nr[pos] // 14
	mod = pos___stones_nr[pos] % 14
	result = list(pos___stones_nr)
	result[pos] = 0
	result = [x + div for x in result]
	for p in range(pos + 1, pos + mod + 1):
		result[p % 14] += 1
	ans = sum((x for x in result if x % 2 == 0))
	return ans
pos___stones_nr = tuple((int(x) for x in input().split()))
best_score = -1
for pos in range(14):
	best_score = max(best_score, get_score(pos, pos___stones_nr))
print(best_score)


import math
a = list(map(int, input().split()))
m = 0
for i in range(0, 14):
	b = a[:]
	b[i % 14] = 0
	for j in range(0, a[i] % 14):
		b[(i + 1 + j) % 14] += 1
	for j in range(0, 14):
		b[j] += math.floor(a[i] / 14)
	b = [i for i in b if i % 2 == 0]
	if sum(b) > m:
		m = sum(b)
print(m)


n = 14
a = list(map(int, input().split()))
ans = 0
for i in range(n):
	if a[i] != 0:
		c = a[i] // 14
		d = a[i] % 14
		ans1 = 0
		for j in range(i + 1, i + n):
			qq = 0
			if d > 0:
				qq = 1
				d -= 1
			if (a[j % n] + c + qq) % 2 == 0:
				ans1 += a[j % n] + c + qq
		if c % 2 == 0:
			ans1 += c
		ans = max(ans, ans1)
print(ans)


from copy import deepcopy
holes = [int(x) for x in input().split()]
m = 0
for i in range(14):
	game = deepcopy(holes)
	if game[i] == 0:
		continue
	stones = game[i]
	(loops, remainder) = divmod(stones, 14)
	game[i] = 0
	for j in range(14):
		game[j] += loops
	for j in range(remainder):
		game[(i + j + 1) % 14] += 1
	s = 0
	for j in range(14):
		if game[j] & 1 == 0:
			s += game[j]
	if s > m:
		m = s
print(m)


import sys
data = sys.stdin.readlines()
lis = []
for line in data:
	lis.append(line)

def win(Seq, pos):
	s = 0
	seq = Seq[:]
	val = seq[pos]
	val2 = val // 14
	seq[pos] = 0
	for i in range(14):
		seq[i] += val2
	for i in range(1, val - 14 * val2 + 1):
		ind = (pos + i) % 14
		seq[ind] += 1
	for i in range(14):
		if seq[i] % 2 == 0:
			s += seq[i]
	return s
seq = list(map(int, lis[0].split()))
m = 0
for i in range(14):
	if seq[i] == 0:
		continue
	tmp = win(seq, i)
	if tmp > m:
		m = tmp
print(m)


a = [int(w) for w in input().split()]

def score(i):
	b = a[i + 1:] + a[0:i] + [0]
	for j in range(14):
		b[j] += a[i] // 14
	for j in range(a[i] % 14):
		b[j] += 1
	return sum((x for x in b if x % 2 == 0))
print(max((score(i) for i in range(14))))


from pprint import pprint
a = list(map(int, input().split()))
mask = [[a[i] // 14 + (1 if (j - i) % 14 <= a[i] % 14 and a[i] > 0 and (j != i) else 0) for j in range(14)] for i in range(14)]

def s(w):
	r = 0
	for i in range(14):
		if w != i:
			l = a[i] + mask[w][i]
		else:
			l = mask[w][i]
		if l % 2 == 0:
			r += l
	return r
res = 0
for w in range(14):
	if a[w]:
		res = max(res, s(w))
print(res)


stones = [int(i) for i in input().split(' ')]
sums = []
for begin in range(14):
	new_stones = stones[:]
	stones_begin = stones[begin]
	new_stones[begin] = 0
	i = begin + 1
	if i == 14:
		i = 0
	rounds = stones_begin // 14
	new_stones = [i + rounds for i in new_stones]
	stones_begin %= 14
	while stones_begin > 0:
		stones_begin -= 1
		new_stones[i] += 1
		i += 1
		if i == 14:
			i = 0
	s = 0
	for stone in new_stones:
		if stone % 2 == 0:
			s += stone
	sums.append(s)
print(max(sums))


pole_i = list(map(int, input().split()))
ans = []
for i in range(len(pole_i)):
	summ = 0
	pole = pole_i.copy()
	if pole[i] != 0:
		ruka = pole[i]
		vsem = ruka // 14
		ne_vsem = ruka % 14
		pole[i] = 0
		for j in range(len(pole)):
			pole[j] += vsem
			if j > i:
				if i + ne_vsem >= j:
					pole[j] += 1
			elif j < i:
				if j <= ne_vsem - (14 - i):
					pole[j] += 1
	for i in pole:
		if i % 2 == 0:
			summ += i
	ans.append(summ)
print(max(ans))


from copy import copy
n = 14
ans = 0
arr = list(map(int, input().split()))
for i in range(14):
	if arr[i] == 0:
		continue
	pss = arr[i] // 14
	q = arr[i] % 14
	brr = copy(arr)
	brr[i] = 0
	j = (i + 1) % 14
	while q > 0:
		brr[j] += 1
		q -= 1
		j = (j + 1) % 14
	for z in range(14):
		brr[z] += pss
	curr = 0
	for z in range(14):
		if brr[z] % 2 == 0:
			curr += brr[z]
	ans = max(curr, ans)
print(ans)


def calcScore(stones):
	(bank, stones[-1]) = (stones[-1], 0)
	score = 0
	for (i, count) in enumerate(stones):
		newCount = count + max(0, bank - i + len(stones) - 1) // len(stones)
		if newCount % 2 == 0:
			score += newCount
	return score
stones = list(map(int, input().split()))
maxScore = max((calcScore(stones[i:] + stones[:i]) for i in range(len(stones))))
print(maxScore)


nums = list(map(int, input().strip().split()))
mmax = 0
for i in range(14):
	score = 0
	cur = nums[i]
	if cur == 0:
		continue
	for j in range(14):
		dist = j - i
		if j <= i:
			dist = 14 - i + j
		if cur % 14 < dist:
			add = cur // 14
		else:
			add = cur // 14 + 1
		if j == i:
			tmp = add
		else:
			tmp = nums[j] + add
		if tmp % 2 == 0:
			score += tmp
	mmax = max(mmax, score)
print(mmax)


initial = list(map(int, input().split()))
max1 = 0
newlist = list()
newlist.append(initial[0])
for i in range(14):
	num = initial[i]
	if num != 0:
		copy = list(initial)
		copy[i] = 0
		s = 0
		times = num // 14
		for j in range(14):
			j = (i + j + 1) % 14
			copy[j] += times
		num = num % 14
		for j in range(num):
			j = (i + j + 1) % 14
			copy[j] += 1
		for j in range(14):
			if copy[j] % 2 == 0:
				s = s + copy[j]
		if s > max1:
			max1 = s
print(max1)


stones = list(map(int, input().split()))
scores = []
for i in range(14):
	full = stones[i] // 14
	part = stones[i] % 14
	result = [(stones[j] if i != j else 0) + full for j in range(14)]
	for j in range(i + 1, i + part + 1):
		result[j % 14] += 1
	scores.append(sum((r for r in result if r % 2 == 0)))
print(max(scores))


def Mancalla():
	mancalla = [int(i) for i in input().strip().split()]
	scores = list()
	for i in range(14):
		if mancalla[i]:
			temp = mancalla[:]
			(j, temp[i]) = (temp[i], 0)
			(j, r) = (j % 14, j // 14)
			temp = [i + r for i in temp]
			for k in range(1, j + 1):
				if i + k >= 14:
					new_i = i + k - 14
				else:
					new_i = i + k
				temp[new_i] += 1
			temp = [i for i in temp if i & 1 == 0]
			scores.append(sum(temp))
	return max(scores)
a = Mancalla()
print(a)


a = list(map(int, input().split()))
mx = 0
for i in range(len(a)):
	b = []
	for k in a:
		b.append(k)
	b[i] = 0
	c = a[i] // 14
	cc = a[i] % 14
	for j in range(len(b)):
		b[j] += c
	k = i + 1
	while cc != 0:
		k %= 14
		b[k] += 1
		k += 1
		cc -= 1
	kl = 0
	for j in range(len(b)):
		if b[j] % 2 == 0:
			kl += b[j]
	mx = max(mx, kl)
print(mx)


values = [int(x) for x in input().split(' ')]
ans = 0
for i in range(14):
	tempList = list(values)
	curr = 0
	(val, tempList[i]) = (values[i], 0)
	value_to_add = val // 14
	index = val % 14
	for j in range(i + 1, i + 1 + index):
		tempList[j % 14] += 1
	for j in range(14):
		tempList[j] += value_to_add
		if tempList[j] % 2 == 0:
			curr += tempList[j]
	ans = max(ans, curr)
print(ans)


a = list(map(int, input().split()))
n = len(a)
k = [i for i in a]
lst = []
for i in range(n):
	p = k[i] % n
	ans = 0
	a = k[i + 1:] + k[:i + 1]
	a[-1] = 0
	for j in range(n):
		if (a[j] + 1 + int(k[i] // n)) % 2 == 0 and j < p:
			ans += a[j] + 1 + int(k[i] // n)
		elif (a[j] + int(k[i] // n)) % 2 == 0 and j >= p:
			ans += a[j] + int(k[i] // n)
	lst.append(ans)
print(max(lst))


a = list(map(int, input().strip().split()))

def move(b, bin_index):
	board = b[:]
	amount = board[bin_index]
	board[bin_index] = 0
	if amount < 1:
		return board
	f14s = amount // 14
	amount = amount % 14
	if f14s:
		for i in range(len(board)):
			board[i] += f14s
	while amount > 0:
		next_index = (bin_index + 1) % 14
		board[next_index] += 1
		amount -= 1
		bin_index += 1
	return board

def score(board):
	total = 0
	for board_bin in board:
		if board_bin % 2 == 0:
			total += board_bin
	return total
max_score = -1
for i in range(len(a)):
	max_score = max(score(move(a, i)), max_score)
print(max_score)


a = list(map(int, input().split()))
m = 0
for i in range(14):
	if a[i] == 0:
		continue
	b = [0] * 14
	for j in range(14):
		b[j] = a[j]
	z = b[i]
	b[i] = 0
	for j in range(14):
		b[j] += z // 14
	for j in range(1, z % 14 + 1):
		b[(i + j) % 14] += 1
	s = 0
	for j in range(14):
		if b[j] % 2 == 0:
			s += b[j]
	if m < s:
		m = s
print(m)


a = list(map(int, input().split()))
num = 0
for i in range(14):
	b = a[:]
	b[i] = 0
	k = a[i]
	q = k // 14
	p = k % 14
	for j in range(i + 1, i + 15):
		if j >= 14:
			j -= 14
		b[j] += q + int(p > 0)
		p -= 1
	tmp = 0
	for j in range(14):
		if b[j] % 2 == 0:
			tmp += b[j]
	num = max(num, tmp)
print(num)


a = list(map(int, input().split()))
ans = 0
for i in range(14):
	ss = a[i]
	m = 0
	for j in range(1, 15):
		p = (i + j) % 14
		if ss == 0:
			if j != 14 and a[p] % 2 == 0:
				m += a[p]
			continue
		ns = ss // 14
		if ss % 14 != 0:
			ns += 1
		if j != 14 and (ns + a[p]) % 2 == 0:
			m += ns + a[p]
		elif j == 14 and ns % 2 == 0:
			m += ns
		ss -= 1
	ans = max(ans, m)
print(ans)


a = list(map(int, input().split()))
s = 0
for i in range(14):
	l = 0
	if a[i] % 2 == 1:
		k = a[i] // 14
		p = a[i] % 14
		b = a[:]
		b[i] = 0
		for j in range(1, p + 1):
			b[(i + j) % 14] = b[(i + j) % 14] + 1
		for j in range(14):
			if (b[j] + k) % 2 == 0:
				l += b[j] + k
		s = max(s, l)
print(s)


ai = list(map(int, input().split()))
mch = 0
for i in range(14):
	if ai[i] > 0:
		a = ai[:]
		k = a[i]
		a[i] = 0
		for j in range(14):
			a[j] += k // 14
		k %= 14
		for j in range(1, k + 1):
			a[(i + j) % 14] += 1
		ch = 0
		for j in range(14):
			if a[j] % 2 == 0:
				ch += a[j]
		if ch > mch:
			mch = ch
print(mch)


a = list(map(int, input().split()))
ANS = c = 0
for i in range(14):
	x = a[0] // 14
	y = a[0] % 14
	s = sum(a) - a[0]
	l = sum(a[1:y + 1])
	try:
		n = a[1:y + 1].count(0)
	except:
		n = 0
	try:
		z = a[y + 1:].count(0) + 1
	except:
		z = 1
	if x % 2 == 0:
		ANS = y - n + l + x * (y - n) + x * z
	else:
		ANS = s - l + x * (14 - y - z) + n + x * n
	c = max(ANS, c)
	a.append(a[0])
	a.remove(a[0])
print(c)


a = list(map(int, input().strip().split()))[:14]
i = 0
ans = 0
while i < 14:
	dis = a[i] // 14
	mod = a[i] % 14
	b = a[:]
	res = 0
	j = 1
	b[i] = 0
	while j <= 14:
		x = b[(i + j) % 14]
		x += dis
		if mod:
			x += 1
			mod -= 1
		if x % 2 == 0:
			res += x
		j += 1
	i += 1
	ans = max(ans, res)
print(ans)


a = list(map(int, input().split()))
num = 0
for i in range(14):
	rec = 0
	p = a[:]
	q = p[i] // 14
	mod = p[i] % 14
	p[i] = 0
	if q > 0:
		for j in range(14):
			p[j] += q
	j = i + 1
	while mod > 0:
		if j == 14:
			j = 0
		p[j] += 1
		j += 1
		mod -= 1
	for k in range(14):
		if p[k] % 2 == 0:
			rec += p[k]
	num = max(num, rec)
print(num)


a = list(map(int, input().split()))
max_p = 0
for i in range(14):
	b = a.copy() + a.copy()
	p = 0
	d = a[i] // 14
	r = a[i] % 14
	b[i + 14] = 0
	for j in range(i + 1, i + 15):
		b[j] += d
		if j - i <= r:
			b[j] += 1
	for j in range(i + 1, i + 15):
		if b[j] % 2 == 0:
			p += b[j]
	if p > max_p:
		max_p = p
print(max_p)


v = [int(x) for x in input().split()]
max = 0
for i in range(14):
	if v[i] != 0:
		s = 0
		nrp1 = v[i] // 14
		nrp2 = v[i] % 14
		cpy = v[i]
		v[i] = 0
		if nrp1 != 0:
			for j in range(14):
				el = v[j] + nrp1
				if j < i and (i + nrp2) % 14 >= j and (i + nrp2 >= 14) or (j > i and i + nrp2 >= j):
					el += 1
				if el % 2 == 0:
					s += el
		else:
			j = i
			while nrp2:
				j = (j + 1) % 14
				el = v[j] + 1
				if el % 2 == 0:
					s += el
				nrp2 -= 1
		if s > max:
			max = s
		v[i] = cpy
print(max)


b = input().split()
b = [int(n) for n in b]
mask = [x % 2 == 0 for x in b]
maxa = 0
for i in range(0, len(b)):
	new_mask = mask
	new_b = list(b)
	new_b[i] = 0
	new_b = [x + int(b[i] / 14) for x in new_b]
	score = 0
	for a in range(0, b[i] % 14):
		idx = (i + a + 1) % 14
		new_b[idx] += 1
	for x in new_b:
		if x % 2 == 0:
			score += x
	maxa = max(score, maxa)
print(maxa)


stones = list(map(int, input().split()))
scores = []
for x in range(14):
	if stones[x] != 0:
		temp = stones[:]
		for y in range(14):
			temp[y] += stones[x] // 14
		a = x
		for y in range(stones[x] % 14):
			if a == 13:
				a = 0
			else:
				a += 1
			temp[a] += 1
		temp[x] -= stones[x]
		s = 0
		for y in temp:
			if y % 2 == 0:
				s += y
		scores.append(s)
print(max(scores))


def f(a, x, y, i):
	a[i] = 0
	i = (i + 1) % 14
	while y != 0:
		a[i] += 1
		i = (i + 1) % 14
		y -= 1
	s = 0
	for i in range(14):
		a[i] += x
		if a[i] % 2 == 0:
			s = s + a[i]
	return s
arr = list(map(int, input().split()))
m = 0
for i in range(14):
	if arr[i] == 0:
		next
	else:
		x = arr[i] // 14
		y = arr[i] % 14
		q = f(arr.copy(), x, y, i)
		if q > m:
			m = q
print(m)


board = list(map(int, input().split()))
ans = 0
for i in range(14):
	if board[i] != 0:
		div = board[i] // 14
		rem = 0
		if div == 0:
			rem = board[i]
		else:
			rem = board[i] % 14
		temp = [x + div for x in board]
		temp[i] = div
		k = i + 1
		for j in range(rem):
			if k >= 14:
				k = 0
			temp[k] += 1
			k += 1
		tSum = 0
		for j in temp:
			if j % 2 == 0:
				tSum += j
		if tSum > ans:
			ans = tSum
print(ans)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))

def fn(p):
	turns = b[p] // 14
	a = b.copy()
	sm = 0
	a[p] = 0
	for i in range(1, 15):
		a[(p + i) % 14] += turns
	rem = b[p] % 14
	for i in range(p + 1, p + rem + 1, 1):
		a[i % 14] += 1
	for i in range(14):
		if a[i] & 1 == 0:
			sm += a[i]
	return sm
for _ in range(1):
	b = lst()
	ans = 0
	for i in range(14):
		if b[i] != 0:
			ans = max(ans, fn(i))
	print(ans)


a = list(map(int, input().split(' ')))
best = 0
for i in range(len(a)):
	c = a[i]
	aa = a.copy()
	aa[i] = 0
	p = int(c / 14)
	m = c % 14
	aaa = [aa[j] + p for j in range(14)]
	for j in range(m):
		aaa[(i + j + 1) % 14] += 1
	sum = 0
	for j in range(14):
		if aaa[j] % 2 == 0:
			sum += aaa[j]
	if sum > best:
		best = sum
print(best)


import sys
input = sys.stdin.readline
S = list(map(int, input().split()))
SCORES = []
for i in range(14):
	TMP = [x for x in S]
	if TMP[i] != 0:
		stones = TMP[i]
		TMP[i] = 0
		TMP = [x + stones // 14 for x in TMP]
		for j in range(stones % 14):
			TMP[(i + j + 1) % 14] += 1
		SCORES.append(sum([x for x in TMP if x % 2 == 0]))
print(max(SCORES))


numbers = list(map(int, input().split()))
v = []
for i in range(14):
	v.append(numbers[i])
result = 0
for i in range(14):
	k = numbers[i]
	v[i] = 0
	c = int(k / 14)
	d = k % 14
	for j in range(14):
		v[j] = v[j] + c
	j = i + 1
	while j <= 13 and d > 0:
		v[j] = v[j] + 1
		j = j + 1
		d = d - 1
	for j in range(d):
		v[j] = v[j] + 1
	suma = 0
	for j in range(14):
		if v[j] % 2 == 0:
			suma = suma + v[j]
	result = max(result, suma)
	for j in range(14):
		v[j] = numbers[j]
print(result)


from copy import copy
l = list(map(int, input().split(' ')))
mx = 0
for i in range(14):
	if l[i]:
		a = l[i]
		temp_l = copy(l)
		temp_l[i] = 0
		(b, a) = divmod(a, 14)
		for x in range(14):
			temp_l[x] += b
		x = i
		while a:
			x = (x + 1) % 14
			temp_l[x] += 1
			a -= 1
		c = 0
		for x in temp_l:
			if not x % 2:
				c += x
		if c > mx:
			mx = c
print(mx)


a = list(map(int, input().split()))
ans = 0
b = [0] * 14
for i in range(14):
	for l in range(14):
		b[l] = a[l]
	cnt = 0
	k = a[i] // 14
	k2 = a[i] % 14
	b[i] = 0
	for j in range(14):
		b[j] += k
	for j in range(i + 1, i + k2 + 1):
		b[j % 14] += 1
	for j in range(14):
		if b[j] % 2 == 0:
			cnt += b[j]
	if ans < cnt:
		ans = cnt
print(ans)


a = list(map(int, input().split()))
sum1 = 0
for i in range(14):
	sum = 0
	if not a[i] == 0:
		m = a[i] % 14
		r = a[i] // 14
		cnt = 0
		if i == 13:
			j = 0
		else:
			j = i + 1
		if r >= 1:
			while cnt < 13:
				if cnt < m:
					if (a[j] + r + 1) % 2 == 0:
						sum += a[j] + r + 1
				elif (a[j] + r) % 2 == 0:
					sum += a[j] + r
				cnt += 1
				if j == 13:
					j = 0
				else:
					j += 1
			if r % 2 == 0:
				sum += r
		else:
			while cnt < m:
				if (a[j] + r + 1) % 2 == 0:
					sum += a[j] + r + 1
				cnt += 1
				if j == 13:
					j = 0
				else:
					j += 1
	if sum1 < sum:
		sum1 = sum
print(sum1)


arr = list(map(int, input().split()))
score = 0
for i in range(14):
	if arr[i] > 0:
		a = arr[:]
		k = a[i]
		a[i] = 0
		for j in range(14):
			a[j] += k // 14
		k %= 14
		for j in range(i + 1, i + 1 + k):
			a[j % 14] += 1
		temp = 0
		for j in range(14):
			if a[j] % 2 == 0:
				temp += a[j]
		score = max(score, temp)
print(score)


lst = [int(x) for x in input().split()]
lst1 = [str(x) for x in lst]
s = 0
for i in range(14):
	lst2 = [int(x) for x in lst1]
	k = lst2[i]
	j = i
	lst2[j] = 0
	while k > 0:
		a = k // 14
		k = k % 14
		if a > 0:
			lst2 = [x + a for x in lst2]
		if j == 13:
			j = -1
		if k > 0:
			lst2[j + 1] = lst2[j + 1] + 1
			k -= 1
			j += 1
	s1 = 0
	for i in range(14):
		if lst2[i] % 2 == 0:
			s1 += lst2[i]
	s = max(s, s1)
print(s)


a = list(map(int, input().split()))
m = 0
for i in range(0, 14):
	c = 0
	b = a.copy()
	if b[i] != 0:
		k = b[i]
		b[i] = 0
		for j in range(i + 1, 14):
			b[j] += 1
			k -= 1
			if k == 0:
				break
		p = k // 14
		k = k % 14
		for j in range(0, 14):
			b[j] = b[j] + p
		for j in range(0, 14):
			if k == 0:
				break
			b[j] += 1
			k -= 1
		for j in range(0, 14):
			if b[j] % 2 == 0:
				c = c + b[j]
		if c > m:
			m = c
print(m)


l = [int(x) for x in input().split()]
max = 0
for i in range(len(l)):
	m = [x for x in l]
	fist = l[i]
	m[i] = 0
	m = [x + fist // 14 for x in m]
	fist = fist % 14
	j = 1
	while j <= fist:
		m[(i + j) % 14] += 1
		j += 1
	even = sum([x for x in m if x % 2 == 0])
	if even > max:
		max = even
print(max)


mx = -1
n = [int(i) for i in input().split()]
for i in range(14):
	arr = n[:]
	st = arr[i]
	arr[i] = 0
	loop = st // 14
	ans = 0
	for j in range(14):
		arr[j] += loop
	for j in range(1, st % 14 + 1):
		arr[(i + j) % 14] += 1
	for i in arr:
		if i % 2 == 0:
			ans += i
	mx = max(mx, ans)
print(mx)


def sim(poz, l):
	if l[poz] <= 14:
		aux = l[poz]
		l[poz] = 0
		for i in range(1, aux + 1):
			l[(poz + i) % 14] += 1
	else:
		aux = l[poz]
		l[poz] = 0
		for i in range(14):
			l[i] += aux // 14
		for i in range(1, aux % 14 + 1):
			l[(poz + i) % 14] += 1

def score(l):
	s = 0
	for i in range(14):
		if l[i] % 2 == 0:
			s += l[i]
	return s
l = input().split()
for i in range(len(l)):
	l[i] = int(l[i])
v = l.copy()
maxim = 0
for i in range(14):
	sim(i, v)
	if score(v) > maxim:
		maxim = score(v)
	v = l.copy()
print(maxim)


import sys
import math
lista = [int(x) for x in input().strip().split()]
tug = lista
cota = []
maxa = -1000000000.0
for i in range(len(lista)):
	cota = [0 for yu in range(14)]
	suma = 0
	if lista[i] is not 0:
		if lista[i] >= 13 - i:
			flen = 13 - i
			loop = (lista[i] - flen) // 14
			back = lista[i] - loop * 14 - flen
			for j in range(14):
				cota[j] += loop + lista[j]
				if j == i:
					cota[j] -= lista[j]
			for m in range(i + 1, 14):
				cota[m] += 1
			for t in range(0, back):
				cota[t] += 1
		else:
			for j in range(14):
				cota[j] += lista[j]
				if j == i:
					cota[j] -= lista[j]
			flen = lista[i]
			for m in range(i + 1, i + 1 + lista[i]):
				cota[m] += 1
		for i in range(14):
			if cota[i] % 2 == 0:
				suma += cota[i]
			maxa = max(suma, maxa)
print(maxa)


A = list(map(int, input().split()))
B = [0] * 14
f_ans = 0
for i in range(14):
	if A[i] > 0:
		x = A[i] // 14
		y = A[i] % 14
		for j in range(14):
			B[j] = A[j] + x
		B[i] = x
		j = i + 1
		while y > 0:
			B[j % 14] += 1
			j += 1
			y -= 1
		ans = 0
		for i in B:
			if i % 2 == 0:
				ans += i
		f_ans = max(ans, f_ans)
print(f_ans)


arr = [int(i) for i in input().split()]
result = []
for i in range(14):
	copy = list(arr)
	store = copy[i]
	copy[i] = 0
	for j in range(i + 1, i + 14 + 1):
		j = j % 14
		copy[j] += store // 14
	store -= store // 14 * 14
	for j in range(i + 1, i + 14):
		j = j % 14
		if store:
			copy[j] += 1
		else:
			break
		store -= 1
	result.append(sum([i for i in copy if i % 2 == 0]))
print(max(result))


rock = list(map(int, input().split()))
ma = 0
for i in range(14):
	cur_ma = 0
	cur = rock.copy()
	b = cur[i]
	cur[i] = 0
	for j in range(i + 1, 14):
		if b > 0:
			b -= 1
			cur[j] += 1
	for j in range(14):
		cur[j] += b // 14
	for j in range(b % 14):
		cur[j] += 1
	for elem in cur:
		if elem % 2 == 0:
			cur_ma += elem
	ma = max(ma, cur_ma)
print(ma)


import sys
list_of_numbers = list(map(int, sys.stdin.readline().split(' ')))
length = len(list_of_numbers)

def find_value_for_index(list_of_numbers, index, length):
	newlist_of_numbers = list_of_numbers.copy()
	number = newlist_of_numbers[index]
	newlist_of_numbers[index] = 0
	for i in range(length):
		newlist_of_numbers[i] += number // 14
	i = index
	number = number % 14
	while number > 0:
		i = (i + 1) % 14
		newlist_of_numbers[i] += 1
		number -= 1
	score = 0
	for i in newlist_of_numbers:
		if i % 2 == 0:
			score += i
	return score
max_score = 0
for i in range(length):
	if list_of_numbers[i] % 2 != 0:
		score = find_value_for_index(list_of_numbers, i, length)
		if score > max_score:
			max_score = score
print(max_score)


(a, m) = (list(map(int, input().split())), 0)
for i in range(14):
	if a[i] == 0:
		continue
	(b, c, mod) = (a[:], 0, a[i] // 14)
	b[i] = 0
	for j in range(a[i] % 14):
		b[(j + i + 1) % 14] += 1
	for j in b:
		if j % 2 == mod % 2:
			c += j + mod
	m = max(m, c)
print(m)


a = list(map(int, input().split()))
ans = 0
for i in range(14):
	if a[i]:
		arr = a.copy()
		t = a[i]
		arr[i] = 0
		for j in range(i + 1, 14):
			arr[j] += 1
			t -= 1
			if not t:
				break
		for j in range(14):
			arr[j] += t // 14
		for j in range(t % 14):
			arr[j] += 1
		s = 0
		for j in range(14):
			if not arr[j] % 2:
				s += arr[j]
		ans = max(ans, s)
print(ans)


A = [int(i) for i in input().split()]
AA = [A[:] for _ in range(14)]
B = [0] * 14
for i in range(14):
	a = A[i]
	AA[i][i] = 0
	inc = A[i] // 14
	for j in range(14):
		k = (i + 1 + j) % 14
		AA[i][k] += inc
	for j in range(a % 14):
		k = (i + 1 + j) % 14
		AA[i][k] += 1
	for j in range(14):
		B[i] += AA[i][j] if AA[i][j] % 2 == 0 else 0
b = max(B)
print(b)


from copy import deepcopy
T = input().split(' ')
for i in range(14):
	T[i] = int(T[i])
mx = 0
for i in range(14):
	sx = T[0]
	for j in range(13):
		T[j] = T[j + 1]
	T[13] = sx
	S = deepcopy(T)
	S[13] = 0
	for j in range(14):
		S[j] += sx // 14
	for j in range(sx % 14):
		S[j] += 1
	m = 0
	for j in range(14):
		if S[j] % 2 == 0:
			m += S[j]
	if m > mx and sx != 0:
		mx = m
print(mx)


arr = list(map(int, input().split()))
ans = 0
for i in range(14):
	arr.append(arr[i])
for i in range(14):
	parr = 0
	x = arr[i] // 14
	k = arr[i] % 14
	z = i
	j = 1
	while j < 14:
		a = arr[z + j]
		a += x
		if z + j <= i + k:
			a += 1
		if a % 2 == 0:
			parr += a
		j += 1
	if x % 2 == 0:
		parr += x
	if parr > ans:
		ans = parr
print(ans)


a = list(map(int, input().split()))
n = 14
ans = 0
for i in range(n):
	l = list(a)
	x = 0
	c = l[i]
	l[i] = 0
	stones = int(c / n)
	rems = c % 14
	for j in range(n):
		l[j] += stones
	index = i
	for j in range(rems):
		index += 1
		index = index % 14
		l[index] += 1
	for j in range(n):
		if l[j] % 2 == 0:
			x += l[j]
	ans = max(ans, x)
print(ans)


a = list(map(int, input().split()))

def check(a):
	a = a[:]
	x = a[0]
	a[0] = 0
	for i in range(1, 14):
		a[i] += max(0, (x + 14 - i) // 14)
	a[0] = max(0, x // 14)
	return sum((x if x % 2 == 0 else 0 for x in a))
print(max((check(a[i:] + a[:i]) for i in range(14) if a[i] > 0)))


a = list(map(int, input().split()))
a += a
ans = 0
for i in range(14):
	if a[i] != 0:
		x = a[i] // 14
		r = a[i] % 14
		ct = 0
		for j in range(i, i + 14):
			if j == i:
				if x % 2 == 0:
					ct += x
			elif j <= i + r:
				if (x + a[j] + 1) % 2 == 0:
					ct += x + a[j] + 1
			elif (x + a[j]) % 2 == 0:
				ct += x + a[j]
		ans = max(ct, ans)
print(ans)


MAX = 14

def Cloning(li1):
	li_copy = li1[:]
	return li_copy
arr = list(map(int, input().strip().split()))
res = 0
for i in range(MAX):
	if arr[i] > 0:
		tmp = Cloning(arr)
		tmp[i] = 0
		cnt = arr[i]
		m = int(cnt / MAX)
		for k in range(MAX):
			tmp[k] += m
		cnt -= m * MAX
		j = (i + 1) % MAX
		while cnt > 0:
			tmp[j] += 1
			j = (j + 1) % MAX
			cnt -= 1
		sm = 0
		for num in tmp:
			if not num & 1:
				sm += num
		res = max(res, sm)
print(res)


a = [int(i) for i in input().split()]
a2 = a.copy()
index = []
c = []
c2 = 0
for i in range(len(a)):
	if a[i] != 0:
		index.append(i)
for j in range(len(index)):
	i = index[j]
	w = a[index[j]]
	a[index[j]] = 0
	z = index[j] + w % 14
	for p in range(len(a)):
		a[p] += w // 14
		if z > 13 and (p > index[j] or p <= z - 14) or (p <= 13 and z >= p > index[j]):
			a[p] += 1
	for q in a:
		if q % 2 == 0 and q != 0:
			c2 += q
	c.append(c2)
	a = a2.copy()
	c2 = 0
print(max(c))


xs = [int(x) for x in input().split()]
res = 0
for i in range(14):
	newxs = xs[:]
	newxs[i] = 0
	for j in range(14):
		newxs[j] += xs[i] // 14
	for j in range(xs[i] % 14):
		newxs[(i + 1 + j) % 14] += 1
	res = max(res, sum((val for val in newxs if val % 2 == 0)))
print(res)


s = list(map(int, input().split()))
count = 0
for i in range(len(s)):
	x = 2 * s
	c1 = 0
	if s[i] > 0:
		m = s[i]
		x[i] = 0
		x[i + 14] = 0
		t = 0
		if m > 14:
			t = m // 14
			m %= 14
		for j in range(i + 1, i + 15):
			x[j] += t
		for j in range(i + 1, i + m + 1):
			x[j] += 1
		for j in range(len(x)):
			if x[j] % 2 == 0:
				c1 += x[j]
		if c1 > count:
			count = c1
print(count)


stones = list(map(int, input().split()))
ans = 0
n = 14
for i in range(n):
	if stones[i] > 0:
		tmpStone = stones[i]
		tmpList = stones[:]
		tmpList[i] = 0
		loop = tmpStone // 14
		tmpStone %= 14
		for j in range(n):
			tmpList[j] += loop
		k = (i + 1) % 14
		while tmpStone > 0:
			tmpList[k] += 1
			tmpStone -= 1
			k = (k + 1) % 14
		tmpEven = 0
		for j in range(n):
			if tmpList[j] % 2 == 0:
				tmpEven += tmpList[j]
		ans = max(ans, tmpEven)
print(ans)


a = list(map(int, input().split()))
ans = 0
c = 0
for i in range(len(a)):
	b = a.copy()
	if a[i] == 0:
		continue
	fi = b[i]
	b[i] = 0
	f = fi // 14
	xes = fi % 14
	c = 0
	for j in range(14):
		b[j] = b[j] + f
	for j in range(xes):
		b[(i + j + 1) % 14] += 1
	for j in b:
		if j % 2 == 0:
			c = c + j
	ans = max(ans, c)
print(ans)


arr = [int(x) for x in input().split()]
max_score = 0
for i in range(len(arr)):
	if arr[i] == 0:
		continue
	arr_copy = arr[:]
	arr_copy[i] = 0
	all_add = arr[i] // 14
	for j in range(14):
		arr_copy[j] += all_add
	for j in range(arr[i] - all_add * 14):
		arr_copy[(i + j + 1) % 14] += 1
	score = 0
	for j in arr_copy:
		if j > 0 and j % 2 == 0:
			score += j
	max_score = max(max_score, score)
print(max_score)


a = input().split()
for i in range(14):
	a[i] = int(a[i])
ans = 0
for i in range(14):
	b = a.copy()
	ans1 = 0
	b[i] = 0
	k = i
	for j in range(1, 15):
		b[(i + j) % 14] += a[i] // 14
		if j <= a[i] % 14:
			b[(i + j) % 14] += 1
		if b[(i + j) % 14] % 2 == 0:
			ans1 += b[(i + j) % 14]
	ans = max(ans, ans1)
print(ans)


mod = 14
arr = list(map(int, input().split()))
maxx = 0
for i in range(len(arr)):
	if arr[i] > 0:
		arr1 = arr.copy()
		r = arr1[i] % mod
		q = arr1[i] // mod
		arr1[i] = 0
		for j in range(len(arr)):
			arr1[j] += q
		for j in range(1, r + 1):
			arr1[(i + j) % mod] += 1
		score = 0
		for j in range(len(arr1)):
			if arr1[j] % 2 == 0:
				score += arr1[j]
		if score > maxx:
			maxx = score
print(maxx)


ais = list(map(int, input().strip().split()))

def do(i):
	ris = list(ais)
	r = ris[i]
	ris[i] = 0
	for j in range(14):
		ris[(i + 1 + j) % 14] += r // 14 + int(r % 14 > j)
	return sum((ri for ri in ris if ri % 2 == 0))
m = 0
for i in range(14):
	if ais[i] > 0:
		m = max(m, do(i))
print(m)


a = list(map(int, input().split()))
total_sum = 0
for (i, b) in enumerate(a):
	sum = 0
	tmp = b % 14
	ave = b // 14
	for h in range(1, 15):
		tmp_no = (i + h) % 14
		if h <= tmp:
			sub_sum = a[tmp_no] + 1 + ave
		elif tmp_no == i:
			sub_sum = ave
		else:
			sub_sum = a[tmp_no] + ave
		if not sub_sum % 2:
			sum += sub_sum
		total_sum = max(total_sum, sum)
print(total_sum)


l = [int(i) for i in input().split()]
ans = 0
for i in range(14):
	if l[i] != 0:
		a = l[:]
		for j in range(14):
			a[j] += l[i] // 14
		ii = i + 1
		for j in range(l[i] % 14):
			ii %= 14
			a[ii] += 1
			ii += 1
		k = 0
		a[i] -= l[i]
		for j in range(14):
			if a[j] % 2 == 0:
				k += a[j]
		ans = max(ans, k)
print(ans)


arr = list(map(int, input().split()))
best = 0
for i in range(14):
	t = arr[:]
	t[i] = 0
	x = arr[i] // 14
	y = arr[i] % 14
	for j in range(1, y + 1):
		t[(i + j) % 14] += 1
	for j in range(14):
		t[j] += x
	best = max(best, sum((xx for xx in t if xx % 2 == 0)))
print(best)


a = list(map(int, input().split()))
r = 0
for i in range(len(a)):
	t = a[i]
	if t == 0:
		continue
	b = a.copy()
	b[i] = 0
	for j in range(i + 1, i + 1 + len(b)):
		b[j % len(b)] += t // len(b)
	t %= len(b)
	for j in range(i + 1, i + 1 + t):
		b[j % len(b)] += 1
	r = max(r, sum((k for k in b if k % 2 == 0)))
print(r)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 15
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	a = LI()
	r = 0
	for i in range(14):
		t = a[:]
		c = t[i]
		t[i] = 0
		m = c % 14
		for j in range(14):
			t[(i + j + 1) % 14] += c // 14
			if j < m:
				t[(i + j + 1) % 14] += 1
		tr = 0
		for j in range(14):
			if t[j] % 2 == 0:
				tr += t[j]
		if r < tr:
			r = tr
	return r
print(main())


li = input().split(' ')
li = list(map(int, li))
max_marks = 0
for (i, v) in enumerate(li):
	if v > 0:
		l = li.copy()
		l[i] = 0
		if v >= 14:
			q = v // 14
			l = [x + q for x in l]
			v = v % 14
		for x in range(i, i + v):
			l[(x + 1) % 14] += 1
		marks = 0
		for x in l:
			if x % 2 == 0:
				marks += x
		max_marks = max(max_marks, marks)
print(max_marks)


nums = list(map(int, input().split()))
res = 0
for i in range(0, len(nums)):
	copy_nums = nums[:]
	total_chunk = int(copy_nums[i] / len(nums))
	total = int(copy_nums[i] % len(nums))
	copy_nums[i] = 0
	for j in range(0, len(nums)):
		copy_nums[j] = copy_nums[j] + total_chunk
	next = (i + 1) % len(nums)
	while total > 0:
		total = total - 1
		copy_nums[next] = copy_nums[next] + 1
		next = (next + 1) % len(nums)
	wins = 0
	for j in range(0, len(nums)):
		if copy_nums[j] % 2 == 0:
			wins = wins + copy_nums[j]
	res = max(res, wins)
print(res)


src = list(map(int, input().split()))
N = 14
ans = 0
for i in range(N):
	if src[i] == 0:
		continue
	arr = src[:]
	(d, m) = divmod(src[i], N)
	arr[i] = 0
	for j in range(N):
		arr[j] += d
	for j in range(i + 1, i + 1 + m):
		arr[j % N] += 1
	tmp = sum((a for a in arr if a % 2 == 0))
	ans = max(ans, tmp)
print(ans)