l = list(map(int,input().split())) c = list(map(int,input().split())) l2 = [2*(l[0]+l[1]), 2*(l[1]+l[2]),2*(l[2]+l[0])] l2.sort() c.sort(reverse = True) ans = 0 for i in range(3): ans += l2[i]*c[i] print(ans)