a = int(input())
sumsd = 0
n = list(map(int, input().split()))
while n != []:
	maxz = max(n)
	n.pop(len(n)-1)
	sumsd += maxz
	if len(n) == 2:
		for x in range(0, 1):
			if n[x] == 1:
				n.pop(x)
			elif n[x] != maxz:
				n[x] -= 1
				
	else:				
		for x in range(0, len(n)):
			if n[x] == 1:
				n.pop(x)
			elif n[x] != maxz:
				n[x] -= 1
print(sumsd)
			

				