#yui1686 n=int(input()) a=list(map(int,input().split())) s=set(a) print(sum(i for i in a if i-1 not in s))