#include <bits/stdc++.h>
using namespace std;
void mycode();
const long long int infLL = (1LL << 62);
const long long int mod = 998244353;
long long int ceil(long long int a, long long int b) { return (a + b - 1) / b; }
long long int min(long long int a, long long int b) {
  if (a > b)
    return b;
  else
    return a;
}
bool bit_check(long long int a, int i) {
  if ((a & (1LL << i))) return 1;
  return 0;
}
long long int bit_toggle(long long int a, int i) { return (a ^ (1LL << i)); }
long long int bit_sum(long long int a, int i) { return a + (1LL << i); }
long long int bit_sub(long long int a, int i) { return a - (1LL << i); }
long long int mod_power(long long int x, long long int y) {
  long long int p = mod;
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int power_of(long long int a, int b) {
  if (a == 0) return -1;
  return 1 + power_of(a / b, b);
}
long long power(long long int a, long long int b) {
  if (a == 1) return 1;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  mycode();
  return 0;
}
long long int f(long long int v, long long int a) {
  if (v % a == 0)
    return (v / a) * v;
  else
    return (v % a) * ceil(v, a) * ceil(v, a) + (a - v % a) * (v / a) * (v / a);
}
bool cmp2(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  if (a.first == b.first && a.second == b.second)
    return 0;
  else {
    long long int p1 = f(a.second, a.first), p2 = f(b.second, b.first);
    for (int i = 1; i < 5; i++)
      return (p1 - f(a.second, a.first + i)) < (p2 - f(b.second, b.first + i));
    return 0;
  }
}
void mycode() {
  long long int n, k, x;
  cin >> n >> k;
  auto cmp = [](pair<long long int, long long int> left,
                pair<long long int, long long int> right) {
    return cmp2(right, left);
  };
  multiset<pair<long long int, long long int>, decltype(cmp)> q(cmp);
  for (int i = 0; i < n; i++) {
    cin >> x;
    q.insert({1, x});
  }
  unsigned long long int ans = 0, aa, bb, cc, a, b;
  while (k != n) {
    n++;
    bb = (*q.begin()).first;
    cc = (*q.begin()).second;
    q.erase(q.begin());
    q.insert({bb + 1, cc});
  }
  while (!q.empty()) {
    bb = (*q.begin()).first;
    cc = (*q.begin()).second;
    ans += f(cc, bb);
    q.erase(q.begin());
  }
  cout << ans << '\n';
}
