#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int par[100005];
priority_queue<pair<long long, int> > pq;
long long tim(long long carrot, int parts) {
  long long w = carrot / parts;
  return (w) * (w) * (parts - carrot % parts) +
         (w + 1) * (w + 1) * (carrot % parts);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    par[i] = 1;
    pq.push({tim(a[i], 1) - tim(a[i], 2), i});
  }
  for (int i = 0; i < k - n; i++) {
    pair<long long, int> top = pq.top();
    pq.pop();
    long long carrot = a[top.second];
    int parts = ++par[top.second];
    pq.push({tim(carrot, parts) - tim(carrot, parts + 1), top.second});
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += tim(a[i], par[i]);
  }
  cout << ans << endl;
  return 0;
}
