Elections

Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are nn students in the school. Each student has exactly kk votes and is obligated to use all of them. So Awruk knows that if a person gives aiaivotes for Elodreip, than he will get exactly k−aik−ai votes from this person. Of course 0≤k−ai0≤k−ai holds.

Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a1,a2,…,ana1,a2,…,an — how many votes for Elodreip each student wants to give. Now he wants to change the number kk to win the elections. Of course he knows that bigger kk means bigger chance that somebody may notice that he has changed something and then he will be disqualified.

So, Awruk knows a1,a2,…,ana1,a2,…,an — how many votes each student will give to his opponent. Help him select the smallest winning number kk. In order to win, Awruk needs to get strictly more votes than Elodreip.

Input

The first line contains integer nn (1≤n≤1001≤n≤100) — the number of students in the school.

The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1001≤ai≤100) — the number of votes each student gives to Elodreip.

Output

Output the smallest integer kk (k≥maxaik≥maxai) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip.

Examples

Input

5
1 1 1 5 1

Output

5

Input

5
2 2 3 2 2

Output

5

Note

In the first example, Elodreip gets 1+1+1+5+1=91+1+1+5+1=9 votes. The smallest possible kk is 55 (it surely can't be less due to the fourth person), and it leads to 4+4+4+0+4=164+4+4+0+4=16 votes for Awruk, which is enough to win.

In the second example, Elodreip gets 1111 votes. If k=4k=4, Awruk gets 99 votes and loses to Elodreip.

PS(水题原本不想发来着,给别人演示复制了过来,就发出去吧)

代码:

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
using  namespace std;
int main()
{

    int n;
    cin>>n;
    int maxn=0,temp=0;
    double sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>temp;
        sum+=temp;
        maxn=max(maxn,temp);
    }
    int ans=ceil((sum*2)/n);
    if(n*ans==2*sum) ans++;
    if(ans<maxn) cout<<maxn<<endl;
    else  cout<<ans<<endl;
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不会敲代码的小帅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值