import itertools L = list(map(int, input().split())) rby = sorted(list(map(int,input().split())), reverse=True) round = [] for x, y in itertools.combinations(L, 2): round.append((x+y)*2) round.sort() ans = 0 for i, j in zip(round, rby): ans += i * j print(ans)