#include<bits/stdc++.h>
// ex [1,2,5,9]
int maxEle(vector<int>& arr,int n){
	int maxi=INT_MIN;
	for(int i=0;i<n;i++){
		maxi=max(maxi,arr[i]);
	}
	return maxi;
}
int calculateDivisor(vector<int>& arr,int limit , int val, int n){
	int total=0;
	for(int i=0;i<n;i++){
		// this divides 1/1,2/1,5/1,9/1
		total+=ceil((double)arr[i]/(double)val);
		if(total>limit) break;
	}
	return total;
}
int smallestDivisor(vector<int>& arr, int limit)
{
	int n = arr.size();
	int low = 1;
	int high = maxEle(arr,n);
	int ans=-1;

	while(low<=high){
		int mid = (low+high)/2;
		if(calculateDivisor(arr, limit, mid, n)<=limit ){
			ans=mid;
			high=mid-1;
		}
		else{
			low=mid+1;
		}
	}
	return ans;
}