#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long cost(long long r, long long s) {
  long long a1 = r / s;
  long long r1 = r % s;
  return (s - r1) * a1 * a1 + (r1) * (a1 + 1) * (a1 + 1);
}
void solve(long long a[]) {
  priority_queue<pair<long long, long long>> p;
  vector<int> b(n, 1);
  long long c = 0, num = k - n;
  for (int i = 0; i < n; i++) c += a[i] * a[i];
  for (int i = 0; i < n; i++) {
    long long ci = cost(a[i], 1) - cost(a[i], 2);
    p.push({ci, i});
  }
  for (int i = 0; i < num; i++) {
    pair<long long, long long> tp = p.top();
    p.pop();
    c -= tp.first;
    b[tp.second]++;
    long long ci =
        cost(a[tp.second], b[tp.second]) - cost(a[tp.second], b[tp.second] + 1);
    p.push({ci, tp.second});
  }
  cout << c << endl;
}
int main() {
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  solve(a);
}
