#include <bits/stdc++.h>
using namespace std;
struct elem {
  long long x, c = 1;
  long long val;
  long long nval() {
    long long r = x % (c + 1);
    return x / (c + 1) * (x / (c + 1) * (c + 1 - r)) +
           (x / (c + 1) + 1) * ((x / (c + 1) + 1) * r);
  }
  friend bool operator<(elem a, elem b) {
    long long ca = a.val - a.nval(), cb = b.val - b.nval();
    return ca < cb;
  }
};
long long n, k;
int32_t main() {
  cin >> n >> k;
  k = k - n;
  long long sol = 0;
  priority_queue<elem> q;
  for (long long i = 1; i <= n; ++i) {
    elem x;
    cin >> x.x;
    x.c = 1;
    x.val = x.x * x.x;
    sol += x.val;
    q.push(x);
  }
  while (k--) {
    elem x = q.top();
    q.pop();
    sol -= x.val;
    x.val = x.nval();
    x.c++;
    sol += x.val;
    q.push(x);
  }
  cout << sol << "\n";
}
