A - Kvass and the Fair Nut 二分
阅读原文时间:2023年07月10日阅读:2

The Fair Nut likes kvass very much. On his birthday parents presented him nn kegs of kvass. There are vivi liters of kvass in the ii-th keg. Each keg has a lever. You can pour your glass by exactly 11 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by ss liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.

Help him find out how much kvass can be in the least keg or define it's not possible to pour his glass by ss liters of kvass.

Input

The first line contains two integers nn and ss (1≤n≤1031≤n≤103, 1≤s≤10121≤s≤1012) — the number of kegs and glass volume.

The second line contains nn integers v1,v2,…,vnv1,v2,…,vn (1≤vi≤1091≤vi≤109) — the volume of ii-th keg.

Output

If the Fair Nut cannot pour his glass by ss liters of kvass, print −1−1. Otherwise, print a single integer — how much kvass in the least keg can be.

Examples

Input

3 3
4 3 5

Output

3

Input

3 4
5 3 4

Output

2

Input

3 7
1 2 3

Output

-1

Note

In the first example, the answer is 33, the Fair Nut can take 11 liter from the first keg and 22 liters from the third keg. There are 33 liters of kvass in each keg.

In the second example, the answer is 22, the Fair Nut can take 33 liters from the first keg and 11 liter from the second keg.

In the third example, the Fair Nut can't pour his cup by 77 liters, so the answer is −1−1.

#include
#include

using namespace std;

long long v[];

int main()
{
long long n;
long long s;
scanf("%lld %lld",&n,&s);
for(int i=;i<n;++i)
{
scanf("%lld",&v[i]);
}

 long long min\_v=v\[\];  
 for(int i=;i<n;++i)  
 {  
     if(min\_v>v\[i\])  
     {  
         min\_v=v\[i\];  
     }  
 }

 long long sum=;  
 for(int i=;i<n;++i)  
 {  
     sum+=v\[i\]-min\_v;  
 }

 long long left=,right=min\_v,k=-;

 while(left<=right)  
 {  
     long long mid=(left+right)>>;  
     if(sum+(min\_v-mid)\*n >= s)  
     {  
         k=max(mid,k);  
         left=mid+;  
     }  
     else  
     {  
         right=mid-;  
     }  
 }

 printf("%d\\n",k);

 return ;  

}

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章