#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n, k;
long long a[N];
priority_queue<tuple<long long, long long, long long> > pq;
inline long long sq(long long x) { return x * x; }
long long cost(long long len, long long pieces) {
  long long each = len / pieces;
  long long extra = len % pieces;
  long long res = extra * sq(each + 1) + sq(each) * (pieces - extra);
  return res;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> k;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    ans += sq(a[i]);
    long long val = cost(a[i], 1) - cost(a[i], 2);
    long long len = a[i];
    long long pieces = 2;
    pq.push(make_tuple(val, len, pieces));
  }
  for (long long i = 1; i <= k - n; i++) {
    long long val, len, pieces;
    tie(val, len, pieces) = pq.top();
    pq.pop();
    ans -= val;
    long long new_val = cost(len, pieces) - cost(len, pieces + 1);
    pieces++;
    pq.push(make_tuple(new_val, len, pieces));
  }
  cout << ans;
  return 0;
}
