#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  long long a[n];
  long long res = 0;
  priority_queue<pair<long long, pair<int, int>>> pq;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    res += a[i] * a[i];
    if (a[i] > 1) {
      long long x = a[i] / 2;
      long long y = x + (a[i] & 1);
      long long diff = a[i] * a[i] - y * y - x * x;
      pq.push({diff, {i, 2}});
    }
  }
  int cnt = n;
  while (cnt < k) {
    int id = pq.top().second.first;
    int div = pq.top().second.second + 1;
    res -= pq.top().first;
    pq.pop();
    cnt++;
    if (div > a[id]) continue;
    long long xp, yp, rp, xq, yq, rq, p, q;
    xp = a[id] / div;
    yp = xp + 1;
    rp = a[id] % div;
    p = (div - rp) * xp * xp + rp * yp * yp;
    xq = a[id] / (div - 1);
    yq = xq + 1;
    rq = a[id] % (div - 1);
    q = (div - 1 - rq) * xq * xq + rq * yq * yq;
    pq.push({q - p, {id, div}});
  }
  cout << res << '\n';
}
