#include <bits/stdc++.h>
using namespace std;
long long value(int len, int parts) {
  int len1 = len / parts;
  int len2 = len1 + 1;
  int cnt2 = len % parts;
  int cnt1 = parts - cnt2;
  return (long long)cnt1 * len1 * len1 + (long long)cnt2 * len2 * len2;
}
struct S {
  int len;
  int parts;
  long long impr() const { return value(len, parts) - value(len, parts + 1); }
  bool operator<(const S &he) const { return impr() > he.impr(); }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  multiset<S> st;
  int val;
  for (int i = 0; i < n; i++) {
    cin >> val;
    st.insert({val, 1});
  }
  for (int i = 0; i < k - n; i++) {
    S s = *st.begin();
    st.erase(st.begin());
    st.insert(S{s.len, s.parts + 1});
  }
  long long ans = 0;
  for (S s : st) {
    ans += value(s.len, s.parts);
  }
  cout << ans;
}
