n=int(input()) a=list(map(int,input().split())) print(sum([x*(x-1 not in a) for x in a]))