n = int(input())
i = list(map(int, input().split()))
p = 0
while n != 0:
    x = max(i)
    p = p + int(max(i))
    i.remove(max(i))
    n = n-1
    t = 0
    while t != n:
        if i[t] < 0:
            i.pop(t)
            n = n-1
            t=t+1
        elif i[t] < x:
            i[t] = i[t] - 1
            t = t+1
        else:
            t=t+1
print(p)