#include #include using namespace std; int w[5]; int v[5] = {0, 1, 2, 3, 4}; int main() { scanf("%d%d%d%d", &w[1], &w[2], &w[3], &w[4]); int sol = 0; do { int ss = w[v[1]] * w[v[2]] + w[v[3]] * w[v[4]]; if (ss > sol) sol = ss; } while (next_permutation(v + 1, v + 5)); printf("%d\n", sol); return 0; }