#include <bits/stdc++.h>
using namespace std;
long double pi = 3.14159265359;
long long par(long long x, long long y) {
  long long u = x / y;
  return u * u * (y - x % y) + (u + 1) * (u + 1) * (x % y);
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, k, cost = 0;
  cin >> n >> k;
  multiset<pair<long long, pair<long long, long long> >,
           greater<pair<long long, pair<long long, long long> > > >
      con;
  for (long long i = (long long)(1); i <= (long long)(n); i++) {
    long long x;
    cin >> x;
    cost += x * x;
    con.insert({par(x, 1) - par(x, 2), {x, 2}});
  }
  for (long long i = (long long)(1); i <= (long long)(k - n); i++) {
    pair<long long, pair<long long, long long> > p = *con.begin();
    con.erase(con.begin());
    cost -= p.first;
    long long a = p.second.first;
    long long b = p.second.second;
    con.insert({par(a, b) - par(a, b + 1), {a, b + 1}});
  }
  cout << cost << "\n";
}
