Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to $120^{\circ}$. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.

He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles.


-----Input-----

The first and the single line of the input contains 6 space-separated integers a_1, a_2, a_3, a_4, a_5 and a_6 (1 ≤ a_{i} ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.


-----Output-----

Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.


-----Examples-----
Input
1 1 1 1 1 1

Output
6

Input
1 2 1 2 1 2

Output
13



-----Note-----

This is what Gerald's hexagon looks like in the first sample:

$\theta$

And that's what it looks like in the second sample:

$A$

Difficulty: competition

Starter code:

Solutions:
As = list(map(int, input().split()))

def solve(As):
    L = As[0] + As[1] + As[2]
    return L**2 - As[0]**2 - As[2]**2 - As[4]**2

print(max(solve(As), solve(As[1:] + [As[0]])))


#!/usr/bin/env python3
sq = lambda x: x * x
a = list(map(int,input().split()))
print(sq(a[0] + a[1] + a[2]) - sq(a[0]) - sq(a[2]) - sq(a[4]))


import sys

(a1, a2, a3, a4, a5, a6) = map(int, input().split())

def calc(h):
	res = 0
	cur = 1
	while cur <= h:
		res += cur + cur - 1
		cur += 1
	return res

ax1 = a4
ax2 = a6
ans = calc(ax1 + ax2 + a5) - calc(ax1) - calc(ax2) - calc(a2)
print(ans)

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

inc = a[0]
total = 0
while a[1] != 0 and a[5] != 0:
    total += 2* inc + 1
    a[1] -= 1
    a[5] -= 1
    inc += 1

if a[1] == 0 and a[5] == 0:
    inc -= 1
    for i in range(a[2]):
        total += 2 * inc + 1
        inc -= 1
else:
    b = max(a[1], a[5])
    for i in range (b):
        total += 2* inc
    inc -= 1
    for i in range(min(a[2], a[4])):
        total += 2*inc + 1
        inc -= 1

print(total)



def main():
    a = [int(i) for i in input().split()]
    result = 0
    while a.count(1) < 4:
        for i in range(6):
            m = i
            l = i - 1 if i != 0 else 5
            r = i + 1 if i != 5 else 0
            if a[l] > 1 and a[r] > 1:
                result += 2 * a[m] + 1
                a[m] += 1
                a[l] -= 1
                a[r] -= 1
    result += 4 * max(a) + 2
    print(result)
    
main()

from heapq import heapify, heappush, heappop
from collections import Counter, defaultdict, deque, OrderedDict
from sys import setrecursionlimit, maxsize
from bisect import bisect_left, bisect, insort_left, insort
from math import ceil, log, factorial, hypot, pi
from fractions import gcd
from copy import deepcopy
from functools import reduce
from operator import mul
from itertools import product, permutations, combinations, accumulate, cycle
from string import ascii_uppercase, ascii_lowercase, ascii_letters, digits, hexdigits, octdigits

prod = lambda l: reduce(mul, l)
prodmod = lambda l, mod: reduce(lambda x, y: mul(x,y)%mod, l)
argmax = lambda l: l.index(max(l))
argmin = lambda l: l.index(min(l))

def read_list(t): return [t(x) for x in input().split()]
def read_line(t): return t(input())
def read_lines(t, N): return [t(input()) for _ in range(N)]

H = read_list(int)

n = H[3]
ans = 0
left, right = H[4], H[2]
while left > 0 and right > 0:
    left -= 1
    right -= 1
    ans += 2 * n + 1
    n += 1

if left == 0:
    left = H[5]
    while right > 0:
        ans += 2 * n
        right -= 1
        left -= 1
    right = H[1]

else:
    right = H[1]
    while left > 0:
        ans += 2 * n
        right -= 1
        left -= 1
    left = H[5]
    
while H[0] < n:
    ans += 2 * n - 1
    n -= 1
print(ans)
    



import math
import sys


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

s1=inp[0]
s2=inp[1]
s3=inp[2]
s4=inp[3]
s5=inp[4]
s6=inp[5]

a=min(s6,s2)
b=s1+a
c=max(s6,s2)-a

if a==s6:
    d=s3
else:
    d=s5

ans=0

ans+= 2*a*s1+a+a*a-a

ans+= 2*b*c

ans+= 2*d*s4+d+d*d-d

print(ans)

    


import math
def getarea (a):
    return (a*a*math.sqrt(3))/8
x =input("").split(' ')
x = [int(y) for y in x]
a1 = x[0]
a2 = x[1]
a3 = x[2]
a4 = x[3]
a5 = x[4]
a6 = x[5]
if (a2==a5):
    totarea = (a1/2 + a3/2 + a2) * ((a3*math.sqrt(3)/2) + (a4*math.sqrt(3)/2))
    totarea-=getarea(a3)+getarea(a4)+getarea(a1)+getarea(a6)
    print((int)(((4*totarea)/math.sqrt(3))+0.5))
elif (a3==a6):
    totarea = (a2/2 + a4/2 + a3) * ((a4*math.sqrt(3)/2) + (a5*math.sqrt(3)/2))
    totarea-=getarea(a4)+getarea(a5)+getarea(a1)+getarea(a2)
    print((int)(((4*totarea)/math.sqrt(3))+0.5))
else:
    totarea = (a6/2 + a2/2 + a1) * ((a2*math.sqrt(3)/2) + (a3*math.sqrt(3)/2))
    totarea-=getarea(a2)+getarea(a3)+getarea(a5)+getarea(a6)
    print((int)(((4*totarea)/math.sqrt(3))+0.5))
    


def main():
    d = list(map(int, input().split()))
    res = 0
    for i in range(min(d[0], d[2])):
        res += (i + d[1] - 1) * 2 + 3
    for i in range(min(d[3], d[5])):
        res += (i + d[4] - 1) * 2 + 3
    if d[0] != d[2]:
        res += abs(d[0] - d[2]) * 2 * ( min(d[0], d[2]) + d[1] )

    print(res)


main()


a = list(map(int, input().split()))
print((a[0] + a[1] + a[2]) ** 2 - a[0] ** 2 - a[2] ** 2 - a[4] ** 2)

l = [int(a) for a in input().split()]
print(((l[0] + l[1] + l[2]) ** 2) - (l[0] * l[0] + l[2] * l[2] + l[4] * l[4]))


a = list(map(int, input().split()))
print((a[0] + a[1] + a[2])**2 - a[0]**2 - a[2]**2 - a[4]**2)

def read_list(t): return [t(x) for x in input().split()]
def read_line(t): return t(input())
def read_lines(t, N): return [t(input()) for _ in range(N)]

H = read_list(int)

print((H[0] + H[1] + H[2]) ** 2 - H[0] ** 2 - H[2] ** 2 - H[4] ** 2)


s = list(map(int, input().split()))
print((s[0]+s[1]+s[2])**2-s[0]**2-s[2]**2-s[4]**2)


a,b,c,d,e,f=map(int,input().split());print((a+b+c)**2-a**2-c**2-e**2)

a,b,c,d,e,f = map(int,input().split())
print((a+b+c)**2-a*a-c*c-e*e)

s = list(map(int, input().split()))
print((s[0] + s[1] + s[2])**2 - s[0]**2 - s[2]**2 - s[4]**2)

def sqr(x:int) -> int:
    return x*x

a,b,c,d,e,f = list(map(int, input().split()))

if a==b==c==d==e==f:
    print(sqr(a)*6)
else:
    print(sqr(a+b+c)-sqr(a)-sqr(c)-sqr(e))


def intSqrt(x):
    a = 1
    b = x
    while a < b:
        c = (a+b)//2
        if c*c > x:
            b = c
        elif abs(c*c-x) < 0.1:
            a = c
            break
        else:
            a = c+1
    return a
a = [int(x) for x in input().split()]
area = sum([a[i]*a[i+1] for i in range(0,6,2)])
sides = [(a[i]**2+a[i+1]**2+a[i]*a[i+1])**0.5 for i in range(0,6,2)]
semi = sum(sides)/2
print(area+int(intSqrt(16*semi*(semi-sides[0])*(semi-sides[1])*(semi-sides[2])/3)))


# your code goes here
a,b,c,d,e,f = map(int,input().split());
print ((e+d+c)*(e+d+c)-a*a-e*e-c*c)

def __starting_point():
    edges = [int(e) for e in input().split(' ')]
    big_triangle = sum(edges[2:5]) ** 2
    small_triangle1 = edges[0] ** 2
    small_triangle2 = edges[2] ** 2
    small_triangle3 = edges[4] ** 2
    print(big_triangle - small_triangle1 - small_triangle2 - small_triangle3)
__starting_point()

a,b,c,d,e,f=map(int,input().split())
print((a+b+c)**2-a**2-c**2-e**2)

from math import radians, cos, sin, atan2, sqrt, floor, acos

def rotate(point, alpha):
    x = point[0]
    y = point[1]
    return (x * cos(alpha) - y * sin(alpha), x * sin(alpha) + y * cos(alpha))

def crs(a, b):
    return a[0] * b[1] - a[1] * b[0]

def m(end, start):
    return (end[0] - start[0], end[1] - start[1])

def area(poly):
    ret = 0
    n = len(poly)

    for i in range(n):
        j = (i + 1) % n
        ret += crs(poly[i], poly[j])

    return abs(ret) / 2.0

def dist(a, b):
    return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)

def get_next_point(p0, p1, x, y):
    r = ((p1[0] - p0[0]) / x * y, (p1[1] - p0[1]) / x * y)
    r = rotate(r, radians(60))

    return (p1[0] + r[0], p1[1] + r[1])


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


pnt = [(0, 0), (a[0], 0)]

for i in range(1, len(a)):
    pnt.append(get_next_point(pnt[-2], pnt[-1], a[i - 1], a[i]))
    assert((dist(pnt[-2], pnt[-1]) - a[i]) <= 1e-7)


ret = area(pnt) * 4 / sqrt(3)
for i in range(floor(ret), floor(ret) + 3):
    if abs(ret - i) < 1e-7:
        ret = i

print(ret)