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

boxes = {}
for i in a:
    if i in boxes:
        boxes[i] += 1
    else:
        boxes[i] = 1

def change(i):
    global boxes
    tmp = boxes.copy()
    for j in boxes:
        if j > i:
            tmp[j+1] = tmp[j]
            del tmp[j]
    for j in boxes:
        if j < i:
            tmp[j-1] = tmp[j]
            del tmp[j]
    tmp[i] -= 1
    if tmp[i] == 0:
        del tmp[i]
    boxes = tmp
        

while len(boxes) > 1:
    last = max(boxes)
    c += last
    change(last)
print(c)