n=int(input()) a=list(map(int,input().split())) a.sort() d={x:1 for x in a} from heapq import heappush,heappop,heapify ary={x:0 for x in a} heapify(a) while a: v=heappop(a) if v in ary: if v in d: d[v]+=ary[v] else: d[v]=ary[v] if v+1 in d: if v+2 in ary: ary[v+2]+=d[v]*d[v+1] else: ary[v+2]=d[v]*d[v+1] heappush(a,v+2) #print(d) #print(ary) ans=sum(ary.values())+n print(ans)