#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge
#ifdef DONLINE_JUDGE
// palindromic tree is better than splay tree!
#define lld I64d
#endif
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(10);
#ifndef LOCAL
freopen("tallbarn.in","r",stdin);
freopen("tallbarn.out","w",stdout);
#endif
int N;
long long K;
cin >> N >> K;
vector<long long> A(N);
dbl S =0;
for(int i =0; i < N; i++) {
cin >> A[i];
S +=sqrt(A[i]);}
vector<long long> C(N);
long long x =K;
for(int i =0; i < N; i++) {
C[i] =max((dbl)1,sqrt(A[i])/S*K);
x -=C[i];}
set< pair<dbl,int> > dif;
for(int i =0; i < N; i++) dif.insert(make_pair((dbl)A[i]/C[i]/(C[i]+1),i));
for(int i =0; i < x; i++) {
auto it =dif.rbegin();
int v =it->ss;
dif.erase(--dif.end());
C[v]++;
dif.insert(make_pair((dbl)A[v]/C[v]/(C[v]+1),v));}
int kk =0;
set< pair<dbl,int> > difp,difn;
for(int i =0; i < N; i++) {
difp.insert(make_pair((dbl)A[i]/C[i]/(C[i]+1),i));
difn.insert(make_pair((C[i] > 1)?(dbl)A[i]/C[i]/(C[i]-1):1e18,i));}
dbl impa =0;
while(true) {
// kk++;
// if(kk > 5000) break;
int mxdifp =difp.rbegin()->ss, midifn =difn.begin()->ss;
if(difp.rbegin()->ff < difn.begin()->ff+1e-3) break;
impa +=difp.rbegin()->ff-difn.begin()->ff;
difp.erase(--difp.end());
difn.erase(difn.begin());
C[mxdifp]++;
C[midifn]--;
difp.insert(make_pair((dbl)A[mxdifp]/C[mxdifp]/(C[mxdifp]+1),mxdifp));
difn.insert(make_pair((C[midifn] > 1)?(dbl)A[midifn]/C[midifn]/(C[midifn]-1):1e18,midifn));}
dbl ans =0;
long long ansL =0;
for(int i =0; i < N; i++) {
ansL +=A[i]/C[i];
ans +=(dbl)(A[i]%C[i])/C[i];}
// if(abs(ans-floor(ans)-0.5) < 0.07)
// if(K > 20*N && (ans+ansL) > 1e5) while(N > 0) {N++; N--;}
cout << ansL+(long long)round(ans) << "\n";
return 0;}
// look at my code
// my code is amazing