n = int(input())
l = list(map(int, input().split()));
l.sort(reverse = True);

s = 0;
c = 0;
cp = 0;
p = l[0]
for i in l:
    if i != p:
        p = i;
        cp = c;
    if i <= cp:
        break
    s = s + i - cp;
    c = c + 1;
print(s);