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 = l[0]*c[0] + l[1]*c[1] + l[2]*c[2] print(x)