n = int(input()) a = [int(x) for x in input().split()] ans = [] for aa in a: if (aa - 1) not in a: ans.append(aa) print(sum(ans))