input() a=set(map(int,input().split())) print(sum([i if i-1 not in a else 0 for i in a]))