#include <bits/stdc++.h>
using namespace std;
long long inf = 10e5;
long long summ(long long initial_len, long long cuts) {
  if (initial_len % cuts == 0) {
    return initial_len * initial_len / cuts;
  } else {
    long long rem = initial_len % cuts;
    long long each = initial_len / cuts;
    return (each + 1) * (each + 1) * rem + each * each * (cuts - rem);
  }
}
long long profit(long long initial_len, long long cuts) {
  return summ(initial_len, cuts) - summ(initial_len, cuts + 1);
}
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    ans += a[i] * a[i];
  }
  long long times = k - n;
  priority_queue<tuple<long long, long long, long long>> q;
  for (long long i = 0; i < n; i++) {
    q.push(make_tuple(profit(a[i], 1), a[i], 1));
  }
  for (long long i = 0; i < times; i++) {
    long long prof = get<0>(q.top());
    long long val = get<1>(q.top());
    long long curr_cuts = get<2>(q.top());
    q.pop();
    ans -= prof;
    q.push(make_tuple(profit(val, curr_cuts + 1), val, curr_cuts + 1));
  }
  cout << ans << endl;
  return 0;
}
