#include <bits/stdc++.h>   using namespace std;   template <class T>   bool umin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool umax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   int arr[100009], val[100009], n, k;   int ok(int x) {     long long res = 0;     for (int i = 1; i <= n; i++) res += (arr[i] + x - 1) / x;     return (res <= k);   }   long long f(int x, int y) {     int a = x % y, aa = x / y + 1;     int b = y - a, bb = x / y;     return aa * 1LL * aa * a + bb * 1LL * bb * b;   }   set<pair<long long, int> > s;   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , &arr[i]);       val[i] = 1;       if (arr[i] > 1)         s.insert(make_pair(f(arr[i], val[i] + 1) - f(arr[i], val[i]), i));     }     for (int j = 0; j < k - n; j++) {       pair<long long, int> nd = *s.begin();       s.erase(nd);       int i = nd.second;       val[i]++;       if (val[i] < arr[i])         s.insert(make_pair(f(arr[i], val[i] + 1) - f(arr[i], val[i]), i));     }     long long res = 0;     for (int i = 1; i <= n; i++) res += f(arr[i], val[i]);     printf( %lld n , res);     return 0;   }   