import time
n = int(input())
a = list(map(int, input().split()))
c = 0

def remove(n):
    global a
    a = [i for i in a if i != n]

def do():
    global c
    max_ = max(a)
    count = a.count(max_)
    c += count * max_
    remove(max_)
    if 1 in a:
        count = a.count(1)
        remove(1)
    for i in range(len(a)):
        a[i] -= count


while len(a) > 0:
    do()
    

print(c)
