# Topic : Greedy _ 알바생 강호
#
# Python 3 : 3952ms
# PyPy 3 : 192ms
N = int(input())
tips = [ int(input()) for _ in range(N) ]
tips.sort(reverse=True)
result = 0
for i in range(N):
tmp = tips[i] - i
if tmp < 0:
tmp = 0
result += tmp
print(result)