#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5;
int a[MaxN + 5], n, k;
long long ans = 0LL;
long long getval(int x, int y) {
  int cnt = x / y;
  int m = x % y;
  return 1LL * m * (cnt + 1) * (cnt + 1) + 1LL * (y - m) * cnt * cnt;
}
struct node {
  long long val;
  int x, block;
  bool operator<(const node &a) const { return val < a.val; }
};
priority_queue<node> que;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    ans += 1LL * a[i] * a[i];
    que.push((node){getval(a[i], 1) - getval(a[i], 2), a[i], 1});
  }
  int cnt = k - n;
  while (cnt) {
    --cnt;
    node now = que.top();
    que.pop();
    ans -= now.val;
    if (now.block == now.x) continue;
    que.push((node){getval(now.x, now.block + 1) - getval(now.x, now.block + 2),
                    now.x, now.block + 1});
  }
  cout << ans << "\n";
  return 0;
}
