#include <bits/stdc++.h>
using namespace std;
long long int div_floor(const long long int &a, const long long int &b) {
  return a / b - (((a ^ b) < 0) and a % b);
}
long long int div_ceil(const long long int &a, const long long int &b) {
  return a / b + (((a ^ b) >= 0) and a % b);
}
long long int diff(long long int a, long long int cnt) {
  long long int rem = a % cnt;
  return a * a - ((a / cnt + 1) * (a / cnt + 1) * rem +
                  (a / cnt) * (a / cnt) * (cnt - rem));
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int sum = 0;
  multiset<pair<long long int, pair<long long int, long long int> > > mst;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i] * a[i];
    mst.insert({diff(a[i], 2), {a[i], 2}});
  }
  while (n++ < k) {
    auto it = mst.end();
    it--;
    auto el = *it;
    mst.erase(it);
    sum -= el.first;
    long long int x = el.second.first, ct = el.second.second;
    mst.insert({diff(x, ct + 1) - diff(x, ct), {x, ct + 1}});
  }
  cout << sum << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) solve();
}
