#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <class T>
int size(T &&a) {
  return (int)(a.size());
}
ostream &operator<<(ostream &os, string str) {
  for (char c : str) os << c;
  return os;
}
template <class A, class B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << "," << p.second << ')';
}
template <class T>
auto operator<<(ostream &os, T &&x) -> decltype(x.begin(), os) {
  os << '{';
  for (auto it = x.begin(); it != x.end(); ++it)
    os << *it << (it == prev(x.end()) ? "" : " ");
  return os << '}';
}
template <class T>
ostream &operator<<(ostream &os, vector<vector<T>> vec) {
  for (auto x : vec) os << "\n  " << x;
  return os;
}
void dump() {}
template <class T, class... Args>
void dump(T &&x, Args... args) {
  cerr << x << "; ";
  dump(args...);
}
ll val(int a, int d) {
  int x = a / d;
  int r = a % d;
  return ll(x) * x * (d - r) + ll(x + 1) * (x + 1) * r;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  k -= n;
  priority_queue<pair<ll, pii>> pq;
  ll ans = 0;
  for (int i = 0; i < (n); ++i) {
    int a;
    cin >> a;
    ans += ll(a) * a;
    pq.push({val(a, 1) - val(a, 2), {a, 1}});
    0;
    0;
  }
  while (k--) {
    auto x = pq.top();
    pq.pop();
    ans -= x.first;
    0;
    0;
    auto [a, d] = x.second;
    ++d;
    pq.push({val(a, d) - val(a, d + 1), {a, d}});
  }
  cout << ans << '\n';
}
