#include <bits/stdc++.h>
using namespace std;
struct qq {
  long long a, b, c;
  bool operator<(const qq &b) const { return a < b.a; }
};
priority_queue<qq> Q;
long long js(long long a, long long x) {
  long long m = a / x, t = a % x;
  return t * (m + 1) * (m + 1) + (x - t) * m * m;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, k;
  cin >> n >> k;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    qq t;
    t.a = js(x, 1) - js(x, 2);
    t.b = x;
    t.c = 2;
    Q.push(t);
    sum += x * x;
  }
  for (int i = 1; i <= k - n; i++) {
    qq x = Q.top();
    Q.pop();
    sum -= x.a;
    Q.push({js(x.b, x.c) - js(x.b, x.c + 1), x.b, x.c + 1});
  }
  cout << sum << "\n";
  return 0;
}
