#include <bits/stdc++.h>
using namespace std;
long long spf[301];
long long fac[301];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < 301; i++) spf[i] = i;
  for (long long i = 4; i < 301; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < 301; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < 301; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
map<long long, long long> getfactor(long long a) {
  map<long long, long long> m;
  while (a > 1) {
    m[spf[a]]++;
    a /= spf[a];
  }
  return m;
}
long long power(long long x, long long y, long long p) {
  long long 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 gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long inverse(long long a, long long p) { return power(a, p - 2, p); }
long long ncr(long long n, long long r, long long p) {
  if (r > n) return 0;
  if (r == 0) return 1;
  return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;
}
long long val(pair<long long, long long> it) {
  long long ans = 0;
  long long rem = it.first % it.second;
  long long quo = it.first / it.second;
  for (long long i = 1; i <= it.second - rem; i++) ans += quo * quo;
  for (long long i = 1; i <= rem; i++) ans += (quo + 1) * (quo + 1);
  return ans;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n + 1];
  multiset<pair<long long, pair<long long, long long> >,
           greater<pair<long long, pair<long long, long long> > > >
      s;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    s.insert(
        make_pair(a[i] * a[i] - val(make_pair(a[i], 2)), make_pair(a[i], 1)));
  }
  long long count = 1;
  while (count <= k - n) {
    auto it = s.begin();
    pair<long long, long long> p = it->second;
    long long cur = val(make_pair(p.first, p.second + 1));
    cur -= val(make_pair(p.first, p.second + 2));
    s.insert(make_pair(cur, make_pair(p.first, p.second + 1)));
    count++;
    s.erase(it);
  }
  long long ans = 0;
  for (auto it : s) {
    long long rem = it.second.first % it.second.second;
    long long quo = it.second.first / it.second.second;
    for (long long i = 1; i <= it.second.second - rem; i++) ans += quo * quo;
    for (long long i = 1; i <= rem; i++) ans += (quo + 1) * (quo + 1);
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long test = 1;
  while (test--) {
    solve();
  }
}
