Home => ProblemSet => 2.10-13:使数组唯一的最小增量
Problem1473--2.10-13:使数组唯一的最小增量

1473: 2.10-13:使数组唯一的最小增量

Time Limit: 1 Sec  Memory Limit: 128 MB  Submit: 0  Solved: 6
[ Submit ] [ Status ] [ Creator: ][ 参考程序 ]

Description

给你一个整数数组 nums 。每次可以操作任意一个满足 0 <= i < nums.length 的下标 i,并将 nums[i] 递增 1。

返回使 nums 中的每个值都变成唯一的所需要的最少操作次数。

Input

第一行一个整数n
第二行n个整数空格分隔

Output

一个整数,表示让数组元素唯一所需要的最少操作次数

Sample Input Copy

3
1 2 2

Sample Output Copy

1

HINT

样例二:
输入:
6
3 2 1 1 2 7
输出:
6


1<= n <= 10^5
0<=数组元素<=10^5

Source/Category