n = int(input()) ls = list(map(int,input().split())) ls.sort() c = 0 h = 0 for i in ls: if i-c > 1: h += i c = i print(c)