Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. In particular, she may not apply any operation to the array at all.

Formally, after applying some operations Alyona will get an array of n positive integers b1, b2, ..., bn such that 1 ≤ bi ≤ ai for every 1 ≤ i ≤ n. Your task is to determine the maximum possible value of mex of this array.

Mex of an array in this problem is the minimum positive integer that doesn't appear in this array. For example, mex of the array containing 1, 3 and 4 is equal to 2, while mex of the array containing 2, 3 and 2 is equal to 1.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of elements in the Alyona's array.

The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the array.

Output

Print one positive integer — the maximum possible value of mex of the array after Alyona applies some (possibly none) operations.

Example

Input
5
1 3 3 3 6
Output
5
Input
2
2 1
Output
3

Note

In the first sample case if one will decrease the second element value to 2 and the fifth element value to 4 then the mex value of resulting array 1 2 3 3 4 will be equal to 5.

To reach the answer to the second sample case one must not decrease any of the array elements.

题意:给定n个元素的数组,让你输出最大的Mex (是不出现在这个数组中的最小正整数),然而,数组是能够进行调整的,也就是元素的数值可以从大变小。

 #include<bits/stdc++.h>
using namespace std;
int num[];
bool cmp(int a,int b)
{
return a < b;
}
int main()
{
int n,ans;
while(cin>>n) {
for(int i = ;i < n; i++)
scanf("%d",&num[i]);
sort(num,num+n,cmp); //预处理,先把数组num从小到大排序
ans = ; //预设数组没有出现的最小整数是2
for(int i = ; i < n; i++)
{
if(ans <= num[i]) // 当目前的预设ans能够被覆盖时,更新ans
ans++;
}
cout<<ans<<endl;
}
return ;
}

CF | Alyona and Mex的更多相关文章

  1. Codeforces Round #381 (Div. 2)C. Alyona and mex(思维)

    C. Alyona and mex Problem Description: Alyona's mother wants to present an array of n non-negative i ...

  2. Codeforces 740C. Alyona and mex 思路模拟

    C. Alyona and mex time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...

  3. Codeforces Round #381 (Div. 1) A. Alyona and mex 构造

    A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother want ...

  4. Codeforces Round #358 (Div. 2)B. Alyona and Mex

    B. Alyona and Mex time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  5. CodeForces 682B Alyona and Mex (排序+离散化)

    Alyona and Mex 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/B Description Someone gave ...

  6. Alyona and mex

    Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  7. Codeforces Round #358 (Div. 2) B. Alyona and Mex 水题

    B. Alyona and Mex 题目连接: http://www.codeforces.com/contest/682/problem/B Description Someone gave Aly ...

  8. Codeforces Round #381 (Div. 2)C Alyona and mex

    Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be ...

  9. B - Alyona and Mex

    Description Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one oper ...

随机推荐

  1. Ecplise 配置本地 https 测试

    今天做项目,需要关联Office 365.为了实现Office365的用户邮件信息与项目的实时同步,需要建立webhook订阅. Office 365 API 连接  https://graph.mi ...

  2. Python/MySQL(四、MySQL数据库操作)

    Python/MySQL(四.MySQL数据库操作) 一.数据库条件语句: case when id>9 then ture else false 二.三元运算: if(isnull(xx)0, ...

  3. Codeforces Round #436 (Div. 2) D. Make a Permutation!

    http://codeforces.com/contest/864/problem/D 题意: 给出n和n个数(ai <= n),要求改变其中某些数,使得这n个数为1到n的一个排列,首先保证修改 ...

  4. [论文阅读]VERY DEEP CONVOLUTIONAL NETWORKS FOR LARGE-SCALE IMAGE RECOGNITION(VGGNet)

    VGGNet由牛津大学的视觉几何组(Visual Geometry Group)提出,是ILSVRC-2014中定位任务第一名和分类任务第二名.本文的主要贡献点就是使用小的卷积核(3x3)来增加网络的 ...

  5. axios介绍与使用说明 axios中文文档

    本周在做一个使用vuejs的前端项目,访问后端服务使用axios库,这里对照官方文档,简单记录下,也方便大家参考. Axios 是一个基于 Promise 的 HTTP 库,可以用在浏览器和 node ...

  6. PHP 安装与配置(WIN10)

    需要在本地搭个PHP的测试环境,顺手将过程写了下来. 由于不是生产环境,我这里直接选择了最新的PHP版本用来测试. 本地坏境为:windows 10 Pro 1709 PHP版本:php-7.2.3- ...

  7. Git -> Can't start Git: git.exe

    问题描述 导入别人的PyCharm项目后提示:Can't start Git:git.exe 解决办法 Git就是个类似插件,在Git的官网上注册个账号然后每次编译就会自动把程序上传到网上备份.可以方 ...

  8. SSO-单点统一登录系统的设计与实现

    本文主要基于web类应用展开讨论,提供的是一种通用机制和方法,所以不论何种技术栈都可进行相应的具体实现. 实现目标 可以在相同或跨域环境下完成各应用的统一登录/注销 方案原理 本质上是采用了web应用 ...

  9. WebRTC 音频采样算法 附完整C++示例代码

    之前有大概介绍了音频采样相关的思路,详情见<简洁明了的插值音频重采样算法例子 (附完整C代码)>. 音频方面的开源项目很多很多. 最知名的莫过于谷歌开源的WebRTC, 其中的音频模块就包 ...

  10. 将 Net 项目升级 Core项目经验:(三)迁移后的Net Standard版本的类库测试和多平台项目实测

    迁移后的Net Standard版本的类库测试和多平台项目实测 按照第一步的方法,添加一个Net Core的MSTest项目,然后将原来的测试项目下的代码迁移到新测试 项目中,然后引用新的Beyond ...