#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  k -= n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  auto get = [&](int x, int y) {
    int l = x / y;
    int h = l + 1;
    int cnth = x % y;
    int cntl = y - cnth;
    return (long long)l * l * cntl + (long long)h * h * cnth;
  };
  long long ans = 0;
  set<pair<long long, int>> have;
  vector<int> num(n, 1);
  for (int i = 0; i < n; ++i) {
    ans += (long long)a[i] * a[i];
    if (a[i] > num[i]) {
      have.insert(make_pair(-get(a[i], num[i]) + get(a[i], num[i] + 1), i));
    }
  }
  for (int tt = 0; tt < k; ++tt) {
    auto p = *have.begin();
    have.erase(have.begin());
    ans += p.first;
    int i = p.second;
    ++num[i];
    if (a[i] > num[i]) {
      have.insert(make_pair(-get(a[i], num[i]) + get(a[i], num[i] + 1), i));
    }
  }
  cout << ans << '\n';
}
