# Baekjoon-17825-주사위 윷놀이

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

# DFS + Back tracking

courses = {
0: list(range(20))+,
1: [5,20,21,22]+[28,29,30,31],
2: [10,23,24]+[28,29,30,31],
3: [15,25,26,27]+[28,29,30,31],
}
scores = list(range(0,40,2))+[13,16,19]+[22,24]+[28,27,26]+[25,30,35,40]

horses = [
[0,0] for _ in range(4) # courses, course index
]
board =  * 32

result = 0
def dfs(turn):
if turn == 10:
else:
for horse in horses:
if horse != 5: # end horse
if horse+nums[turn]>=len(courses[horse]):
board[courses[horse][horse]] = 0
prev_horse = [horse,horse]
horse = 5
dfs(turn+1)
horse = prev_horse
board[courses[horse][horse]] = 1
else:
prev_horse = [horse,horse]
next_idx = courses[horse][horse+nums[turn]]
score = scores[next_idx]
if board[next_idx] == 0:
result += score
board[courses[horse][horse]] = 0
board[next_idx] = 1
if next_idx in [5,10,15] and horse==0:
horse = next_idx//5
horse = 0
else:
horse = horse+nums[turn]
dfs(turn+1)
board[next_idx] = 0
result -= score
horse,horse = prev_horse,prev_horse
board[courses[horse][horse]] = 1
else:
continue

dfs(0)