#include <bits/stdc++.h>
using namespace std;
long long n, k;
priority_queue<pair<long long, pair<long long, long long>>> pq;
long long divide(long long x, long long y) {
  if (x < y) return 1e16;
  long long t = x / y, rm = x % y;
  t += rm / y;
  rm %= y;
  return rm * (t + 1) * (t + 1) + (y - rm) * t * t;
}
void solve() {
  cin >> n >> k;
  long long ans = 0;
  k -= n;
  while (n--) {
    long long x;
    cin >> x;
    ans += x * x;
    pq.push({x * x - divide(x, 2), {x, 2}});
  }
  while (k--) {
    auto x = pq.top();
    pq.pop();
    ans -= x.first;
    pq.push({divide(x.second.first, x.second.second) -
                 divide(x.second.first, x.second.second + 1),
             {x.second.first, x.second.second + 1}});
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
