l = list(map(int, input().split())) c = sorted(map(int, input().split())) x = (l[0] + l[1]) * 2 y = (l[1] + l[2]) * 2 z = (l[0] + l[2]) * 2 l = sorted([x, y, z]) c = c[::-1] x = 0 for i in range(3): x += l[i] * c[i] print(x)