#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 100;
ll f(ll a, ll b) {
  ll low = a / b;
  ll lowCnt = b - a % b;
  ll highCnt = a % b;
  return low * low * lowCnt + (low + 1) * (low + 1) * highCnt;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  set<pair<ll, ll>> vals;
  vector<ll> a(n);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ans += a[i] * a[i];
    assert(f(a[i], 1) == a[i] * a[i]);
    vals.emplace(f(a[i], 1) - f(a[i], 2), i);
  }
  vector<ll> splitCnt(n, 1);
  for (int i = 0; i < k - n; i++) {
    if (vals.empty()) {
      cout << "foo;\n";
      return 0;
    }
    auto it = *vals.rbegin();
    vals.erase(it);
    ans -= it.first;
    int id = it.second;
    splitCnt[id]++;
    vals.emplace(f(a[id], splitCnt[id]) - f(a[id], splitCnt[id] + 1), id);
  }
  cout << ans << '\n';
  return 0;
}
