#include <bits/stdc++.h>
using namespace std;
struct aaa {
  long long x, y;
};
priority_queue<aaa> q;
bool operator<(aaa a, aaa b) { return a.x < b.x; }
long long n, k, ans, a[200010], mn, b[200010];
long long pd(long long mid) {
  long long i, xlh = 0;
  for (i = 1; i <= n; i++) xlh += (a[i] - 1) / mid + 1;
  return xlh <= k;
}
long long get(long long x, long long y) {
  long long w = x / y, yy = x % y, xx = y - yy;
  return xx * w * w + yy * (w + 1) * (w + 1);
}
int main() {
  long long i, j, hh, w, x, y;
  aaa now;
  scanf("%lld%lld", &n, &k);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i <= n; i++) {
    ans += a[i] * a[i];
    b[i] = 1;
    if (a[i] > 1) q.push(aaa{get(a[i], 1) - get(a[i], 2), i});
  }
  k -= n;
  while (k > 0) {
    k--;
    now = q.top();
    q.pop();
    ans -= now.x;
    b[now.y]++;
    if (a[now.y] > b[now.y])
      q.push(aaa{get(a[now.y], b[now.y]) - get(a[now.y], b[now.y] + 1), now.y});
  }
  printf("%lld", ans);
}
