#include <bits/stdc++.h>
using namespace std;
long long int cal(long long int value, long long int parts) {
  long long int quotient = value / parts;
  long long int remainder = value % parts;
  long long int ans = 0;
  ans += (remainder * (quotient + 1) * (quotient + 1));
  ans += ((parts - remainder) * quotient * quotient);
  return ans;
}
long long int diff(long long int value, long long int parts) {
  long long int intial_part = cal(value, parts);
  long long int one_more_than_initial_part = cal(value, parts + 1);
  long long int difference = intial_part - one_more_than_initial_part;
  return difference;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tttt = 1;
  for (int ttt = 1; ttt <= tttt; ttt++) {
    int n;
    long long int k;
    cin >> n >> k;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    priority_queue<pair<long long int, pair<long long int, long long int>>> pq;
    long long int ans = 0;
    for (int i = 0; i < n; i++) {
      long long int value = a[i];
      long long int parts = 1;
      long long int difference = diff(value, parts);
      pq.push(make_pair(difference, make_pair(value, parts + 1)));
    }
    k -= n;
    while (k--) {
      auto t = pq.top();
      pq.pop();
      long long int value = t.second.first;
      long long int parts = t.second.second;
      long long int difference = diff(value, parts);
      pq.push(make_pair(difference, make_pair(value, parts + 1)));
    }
    while (!pq.empty()) {
      auto t = pq.top();
      pq.pop();
      long long int value = t.second.first;
      long long int parts = t.second.second - 1;
      ans += (cal(value, parts));
    }
    cout << ans;
    cout << endl;
  }
  return 0;
}
