You are given an alphabet consisting of n letters, your task is to make a string of the maximum possible length so that the following conditions are satisfied:   the i-th letter occurs in the string no more than a_{i} times;  the number of occurrences of each letter in the string must be distinct for all the letters that occurred in the string at least once. 


-----Input-----

The first line of the input contains a single integer n (2  ≤  n  ≤  26) — the number of letters in the alphabet.

The next line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^9) — i-th of these integers gives the limitation on the number of occurrences of the i-th character in the string.


-----Output-----

Print a single integer — the maximum length of the string that meets all the requirements.


-----Examples-----
Input
3
2 5 5

Output
11

Input
3
1 1 2

Output
3



-----Note-----

For convenience let's consider an alphabet consisting of three letters: "a", "b", "c". In the first sample, some of the optimal strings are: "cccaabbccbb", "aabcbcbcbcb". In the second sample some of the optimal strings are: "acc", "cbc".

Difficulty: interview

Starter code:

Solutions:
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
arr = arr[::-1]
ans = [arr[0]]
for i in range(1, n):
	if(arr[i] < ans[-1]):
		ans.append(arr[i])
	else:
		ans.append(max(0, ans[-1] - 1))
print(sum(ans))

n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(n - 2, -1, -1):
    a[i] = max(min(a[i], a[i + 1] - 1), 0)
print(sum(a))


n = int(input())
c = list(map(int, input().split()))
ret = set()
for x in c:
    for y in range(x, -1, -1):
        if y not in ret:
            ret.add(y)
            break
print(sum(ret))


n = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
x = set()
res = 0
for i in reversed(sorted(a)):
    while i>0:
        if i in x:
            i-=1
        else:
            res+=i
            x.add(i)
            break
print(res)


n, a, s, v = int(input()), sorted(map(int, input().split()), reverse=True), set(), 0
for ai in a:
    while ai and ai in s:
        ai -= 1
    s.add(ai)
    v += ai
print(v)

N = int(input())
letters = list(map(int, input().split()))
letters.sort()
lennow = 0
for i in range(len(letters) - 2, -1, -1):
    letters[i] = max(0, min(letters[i + 1] - 1, letters[i]))
print(sum(letters))

n = int(input())
rng = [int(t) for t in input().split()]

ans = 0
while len(rng) != 0:
    mx = max(rng)

    if mx <= 0:
        break

    ans += mx

    rng.remove(mx)
    for i in range(len(rng)):
        if rng[i] == mx:
            rng[i] -= 1

print(ans)

n=int(input())
ip=list(map(int,input().split()))
op=[]
count=0
for i in ip:
    if i not in op:
        count+=i
        op.append(i)
    else:
        for j in range(1,i+1):
            if i-j not in op:
                count+=i-j
                op.append(i-j)
                break
            else:
                continue
print(count)


n=int(input())
L=[int(x) for x in input().split()]
L.sort()
L=L[::-1]
ans=0
dis=L[0]+1
for i in L:
    ans+=max(0,min(dis,i))
    dis=min(dis,i)-1
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse = True)
check = set()
ans = 0
for i in l:
    x = i
    while x in check:
        x -= 1
    if x < 0:
        continue
    ans += x
    check.add(x)
print(ans)

n = input()
a_in = list(map(int, input().split()))
a = list(reversed(sorted(a_in)))
prev = 1000000001
ans = 0
for c in a:
    if c >= prev:
        c = prev - 1
    if c <= 0:
        break
    ans += c
    prev = c
print(ans)


n = int(input())
data = list(map(int, input().split()))
answer = 0
for i in range(n):
    if data.count(data[i]) == 1:
        answer += data[i]
    else:
        while data[i] > 0:
            if data.count(data[i]) == 1:
                answer += data[i]
                break
            else:
                data[i] -= 1
print(answer)

n = int(input())
a = [int(s) for s in input().split()]

a.sort()
b = 10**9 + 1
sum = 0
for i in range(n-1, -1, -1):
    if min(a[i], b - 1) < 1:
        break
    sum += min(a[i], b - 1)
    b = min(a[i], b - 1)

print(sum)


3

n = int(input())
a = list(map(int, input().split()))

used = set()
reversed(sorted(a))
i = 0
while i < n:
    if a[i] == 0:
        i += 1
    else:
        if a[i] not in used:
            used.add(a[i])
            i += 1
        else:
            a[i] -= 1
print(str(sum(a)))


n = int(input())
ai = list(map(int,input().split()))
ai.sort()
ai.reverse()
last_num = ai[0]+1
ans = 0
for num in ai:
    if last_num == 0:
        break
    if num >= last_num:
        last_num -= 1
    else:
        last_num = num
    ans += last_num
print(ans)


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)[-1::-1]


for i in range(1, n):
	if l[i] >= l[i-1]:
		l[i] = l[i-1] - 1
	if l[i] < 0:
		l[i] = 0
print(sum(l))  



n = int(input())
data = list(map(int, input().split()))
data.sort()
high = data[-1]
ret = 0
for i in range(n-1, -1, -1):
	chosen = min(data[i], high)
	ret += max(chosen, 0)
	high = chosen-1
print(ret)


n = int(input())
a = [int(x) for x in input().split()]

occ = set()
a.sort(reverse=True)
for i in range(len(a)):
    while a[i] in occ and a[i] > 0:
        a[i] -= 1
    occ.add(a[i])

print(sum(a))


n = int(input())
A = list(map(int, input().split()))
ans = []
for i in range(n):
    if A[i] in ans:
        for j in range(A[i] - 1, 0, -1):
            if j not in ans:
                ans.append(j)
                break
    else:
        ans.append(A[i])
print(sum(ans))        


#!/usr/bin/env python3

n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a, reverse=True)
count = 0
prev = None
for x in a:
  if prev != None and prev <= x:
    x = max(prev - 1, 0)
  count += x
  prev = x
print(count)



def adjust(x,limit):
    if x == 0:
        return 0

    if x <= limit:
        return x-1

    return limit

def __starting_point():

    n = int(input())
    a = list(map(int,input().split()))
    a.sort(key=lambda x:-x)
    #print(a)

    for i in range(1,n):
        a[i] = adjust(a[i-1],a[i])

    print( sum(a) )
__starting_point()

n=int(input())
arr=[int(x) for x in input().split()]
arr=sorted(arr)
arr.reverse()
s=set()
sum=0
flag=0
for i in range(n):
    temp=arr[i]
    while temp in s:
        temp=temp-1
        if temp==0:
            flag=1
            break
    sum+=temp
    s.add(temp)
    if flag==1:
        break
print(sum)

n = int(input())
d = [int(i) for i in input().split()]
d = sorted(d, reverse=True)
for i in range(1, len(d)):
    d[i] = max(0, min(d[i - 1] - 1, d[i]))
print(sum(d))

n = int(input())
s=input()
s=s.split()
a=[]
for i in range(n):
    a.append(int(s[i]))
su=0
d={}
a.sort(reverse=True)
for i in range(len(a)):
    if a[i] not in d:
        su+=a[i]
        d[a[i]]=1
    else:
        t=a[i]-1
        while t>=1 and t in d:
            t-=1
        su+=t
        d[t]=1
        
print(su)