#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
int n, k, a[maxn];
long long ans;
long long cal(int x, int y) {
  int d = x / y;
  int e = x % y;
  return 1ll * d * d * (y - e) + 1ll * (d + 1) * (d + 1) * e;
}
struct node {
  int x, y;
  long long cur, nxt;
  node() {}
  node(int _x, int _y) {
    x = _x, y = _y;
    cur = cal(x, y);
    nxt = cal(x, y + 1);
  }
  bool operator<(const node &A) const { return nxt - cur > A.nxt - A.cur; }
};
priority_queue<node> q;
signed main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    q.push({a[i], 1});
  }
  k -= n;
  while (k--) {
    node p = q.top();
    q.pop();
    q.push({p.x, p.y + 1});
  }
  while (q.size()) {
    node p = q.top();
    q.pop();
    ans += p.cur;
  }
  printf("%lld\n", ans);
}
