n = int(input())
str = input().split()
arr = list(int(x) for x in str)
sum = 0
while len(arr)!=0:
    if max(arr)>0:
        maxel = max(arr)
        kil = arr.count(maxel)
        sum += maxel*kil
        for i in range(0,kil,1):
            arr.remove(arr[-1])
        for i in range(0,len(arr),1):
            arr[i] = arr[i]-kil
    else:
        arr = []
print(sum)