#include <bits/stdc++.h>
using namespace std;
const long long infl = 0x3f3f3f3f3f3f3f3fLL;
const long long infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
const long long mod = 1e9 + 7;
const long long N = 1e5 + 5;
long long score(long long x, long long y) {
  long long z = x / y;
  return z * z * (y - x % y) + (z + 1) * (z + 1) * (x % y);
}
long long del(long long x, long long y) {
  return score(x, y + 1) - score(x, y);
}
void solve() {
  long long n, k;
  cin >> n >> k;
  k -= n;
  vector<long long> a(n), f(n, 1);
  for (long long i = 0; i < n; i++) cin >> a[i];
  set<pair<long long, long long>> s;
  for (long long i = 0; i < n; i++)
    if (a[i] > 1) s.insert({del(a[i], f[i]), i});
  while (k--) {
    pair<long long, long long> p = *s.begin();
    s.erase(p);
    f[p.second]++;
    if (f[p.second] < a[p.second])
      s.insert({del(a[p.second], f[p.second]), p.second});
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) ans += score(a[i], f[i]);
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  long long t = 1;
  while (t--) solve();
  return 0;
}
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
long long divide(long long a, long long b) {
  return (a % mod) * powm(b, mod - 2) % mod;
}
long long norm(long long a) {
  while (a >= mod) a -= mod;
  while (a < 0) a += mod;
  return a;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
