#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int cnt[100005];
int n, k;
long long cost(long long amt, long long divs) {
  divs++;
  return ((amt / divs) + 1LL) * ((amt / divs) + 1LL) * (amt % divs) +
         (amt / divs) * (amt / divs) * (divs - (amt % divs));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%lld", a + i);
  priority_queue<pair<long long, int> > pq;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += a[i] * a[i];
    if (a[i] == 1) continue;
    pq.push(make_pair(a[i] * a[i] - cost(a[i], 1), i));
  }
  for (int i = 1; i <= k - n; i++) {
    pair<long long, int> entry = pq.top();
    pq.pop();
    ans -= entry.first;
    cnt[entry.second]++;
    if (cnt[entry.second] < a[entry.second] - 1) {
      pq.push(make_pair(cost(a[entry.second], cnt[entry.second]) -
                            cost(a[entry.second], cnt[entry.second] + 1),
                        entry.second));
    }
  }
  printf("%lld", ans);
  return 0;
}
