Problem A.
#include <lastweapon/io> using namespace lastweapon; const int N = int(2e5) + 9; LL a[N]; int n; LL z; int main() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif Rush { RD(n); REP(i, n) RD(a[i]); sort(a, a+n); LL z = a[n-1]*a[n-2] + a[1]*a[0]; DWN(i, n-2, 0) z += a[i] * a[i+2]; cout << z << endl; } }