E - 1005

Description

Sergey takes part in a TV show «Battle of Prophets», in another episode of which the task of the participants is guessing the colors of the balls taken by the show host out of the opaque urn. Using a spirit ritual he found out that the urn contains balls of n different colors, and the number of balls of the i-th color is exactly ai. The show host is planning to take out balls one by one until the urn becomes empty, and Sergey will have to say the ball's color every time before it is taken out. Unfortunately, the ancient spirits refuse to help him, and he has to trust his intuition only. Sergey wants to guess the color of as many balls as possible in the worst case and is now thinking how many times he is able to make a correct guess for sure.

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of different colors.

The second line contains n space-separated integers: ai (1 ≤ ai ≤ 109) — the number of balls of the i-th color in the urn.

Output

Output a single integer — the maximal number of balls whose color Sergey can definitely guess.

Sample Input

Input
4
5 2 2 9
Output
9
Input
3
1 2 1
Output
2

题意:

感觉题目就是个坑,前面说的都是无用的话,其实就是让输出一个最大的数!

心得;

有些题目其实问题描述看似非常复杂,但仔细分析便可发现有的题非常简单!

代码:

#include <iostream>
using namespace std;
int main()
{
    int i,j,k,n,max;
    int a[200001];
    while(cin>>n)
    {
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        max=0;
        for(i=0;i<n;i++)
        {
            if(a[i]>max)
            {
                max=a[i];
            }
        }
        cout<<max<<endl;
    }return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值