#include <bits/stdc++.h>
using namespace std;
struct node {
  long long v, k, h;
  inline long long get() const {
    long long base = v / (k + 1);
    long long rem = (v - (k + 1) * base);
    return base * base * (k + 1 - rem) + (base + 1) * (base + 1) * rem;
  }
  bool operator<(const node &rhs) const {
    return h - get() < rhs.h - rhs.get();
  }
};
inline void solve() {
  priority_queue<node> q;
  int n, k;
  cin >> n >> k;
  for (int x, i = 1; i <= n; i++) cin >> x, q.push(node{x, 1, 1ll * x * x});
  for (int i = 1; i <= k - n; i++) {
    node now = q.top();
    q.pop();
    node nx;
    nx.k = now.k + 1;
    nx.h = now.get();
    nx.v = now.v;
    q.push(nx);
  }
  long long ans = 0;
  while (!q.empty()) {
    node now = q.top();
    now.k--;
    ans += now.get();
    q.pop();
  }
  cout << ans << '\n';
}
int t;
int main() {
  t = 1;
  while (t--) solve();
  return 0;
}
