n=int(input()) a=sorted(list(map(int, input().split()))) out=a[0] for i in range(1,n): if a[i]-1!=a[i-1]: out+=a[i] print(out)