#include <bits/stdc++.h>
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const long long INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = std::acos(-1);
const int MOD = 31011;
template <typename T>
inline T read() {
  T X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
const int MAXN = 100005;
const int MAXV = 100005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int A[MAXN];
char S[MAXN];
bool check(int x) {
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] <= x) {
      cnt++;
    } else {
      cnt += (A[i] + x - 1) / x;
    }
  }
  return cnt <= k;
}
long long get(int x) {
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] <= x) {
      ans += (long long)A[i] * A[i];
    } else {
      long long b = (A[i] + x - 1) / x;
      long long c = A[i] / b;
      long long a = A[i] % b;
      long long d = b - a;
      ans += a * (c + 1) * (c + 1) + d * (c * c);
    }
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  std::priority_queue<std::tuple<long long, int, int>> PQ;
  long long old = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
    old += (long long)A[i] * A[i];
    int C = 2;
    long long b = A[i] / C;
    long long c = A[i] % C;
    long long d = C - c;
    PQ.push(
        {(long long)A[i] * A[i] - (b * b * d + (b + 1) * (b + 1) * c), i, 2});
  }
  while (n < k) {
    auto [v, i, e] = PQ.top();
    PQ.pop();
    old -= v;
    int C = e;
    long long b = A[i] / C;
    long long c = A[i] % C;
    long long d = C - c;
    long long old1 = b * b * d + (b + 1) * (b + 1) * c;
    C++;
    b = A[i] / C;
    c = A[i] % C;
    d = C - c;
    long long old2 = b * b * d + (b + 1) * (b + 1) * c;
    PQ.push({old1 - old2, i, e + 1});
    n++;
  }
  printf("%lld\n", old);
  return 0;
}
