#include using namespace std; typedef long long LL; const int N = 310; int a[N]; int n; LL res; int h, t, cnt; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); //策略:从最低直接跳到最高,然后跳到次低,跳到次高... t = n; //双指针开始 while (h < t) { cnt++; res += pow(a[h] - a[t], 2); if (cnt % 2 > 0)h++; else t--; } //输出大吉 cout << res << endl; return 0; }