#include <bits/stdc++.h>
using namespace std;
struct S {
  int64_t v;
  int64_t c;
};
int64_t val(const S& v) {
  int64_t d = v.v / v.c;
  int64_t r = v.v % v.c;
  int64_t ans = 0;
  ans += r * (d + 1) * (d + 1);
  ans += (v.c - r) * d * d;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(20);
  int k, n;
  cin >> k >> n;
  auto cmp = [](const S& lhs, const S& rhs) {
    int64_t lval = val(lhs) - val({lhs.v, lhs.c + 1});
    int64_t rval = val(rhs) - val({rhs.v, rhs.c + 1});
    return lval > rval;
  };
  multiset<S, decltype(cmp)> vals(cmp);
  for (decltype(k) repeat_index = 0; repeat_index < k; repeat_index++) {
    int64_t v;
    cin >> v;
    vals.insert({v, 1});
  }
  for (decltype(n - k) repeat_index = 0; repeat_index < n - k; repeat_index++) {
    auto it = vals.begin();
    auto v = *it;
    vals.erase(it);
    v.c++;
    vals.insert(v);
  }
  int64_t ans = 0;
  for (auto& v : vals) {
    ans += val(v);
  }
  cout << ans << endl;
  return 0;
}
