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


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


while len(a) > 0:
    do()
    if 1 in a:
        count = a.count(1)
        for i in range(count):
            a.remove(1)

print(c)