There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.

It is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).

Write a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.

It is possible that after some change the weight of some boxer is $150001$ (but no more).


-----Input-----

The first line contains an integer $n$ ($1 \le n \le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \dots, a_n$, where $a_i$ ($1 \le a_i \le 150000$) is the weight of the $i$-th boxer.


-----Output-----

Print a single integer — the maximum possible number of people in a team.


-----Examples-----
Input
4
3 2 4 1

Output
4

Input
6
1 1 1 4 4 4

Output
5



-----Note-----

In the first example, boxers should not change their weights — you can just make a team out of all of them.

In the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.

Difficulty: introductory

Starter code:

Solutions:
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=set()
for val in arr:
  if val!=1 and val-1 not in s:
      s.add(val-1)
  elif val not in s:
    s.add(val)
  elif val+1 not in s:
    s.add(val+1)
print(len(s))

n = int(input())
arr = list(map(int,input().split()))
arr = sorted(arr)
l = [0 for i in range(150150)]
for val in arr:
    for j in range(-1, 2):
        if val + j == 0:
            continue
        if l[val + j] == 0:
            l[val + j] = 1
            break
ans = 0
for i in range(1, 150150):
    ans += l[i]
print(ans)

n = int(input())
c = sorted(list(map(int,input().split())))
last = 0
ans = 0
for i in (c):
	if(last>i):
		continue
	elif(last<i-1):
		last = i-1
		ans+=1
	elif(last==i-1):
		last = i
		ans+=1
	else:
		last = i+1
		ans+=1
print(ans)


n = int(input())
A = [int(i) for i in input().split()]

A.sort()

if A[0] > 1:
    A[0] -= 1

ans = 1

for i in range(1,n):
    if A[i] == A[i-1]:
        A[i]+=1
        ans += 1
    elif A[i] > A[i-1] + 1:
        A[i]-=1
        ans +=1
    elif A[i] > A[i-1]:
        ans += 1
    else:
        A[i] = A[i-1]

print(ans)


n=int(input())
r=[int(x) for x in input().split()]
r.sort()
t=0
boxers=0
for i in range(n):
    if r[i]>t+1:
        boxers+=1
        t=r[i]-1
    elif r[i]==t+1:
        boxers+=1
        t=r[i]
    elif r[i]==t:
        boxers+=1
        t=r[i]+1
print(boxers)

import math
# helpful:
# r,g,b=map(int,input().split())
#list1 = input().split()
#for i in range(len(list1)):
#    list1[i] = int(list1[i])
#print(list1)
# arr = [[0 for x in range(columns)] for y in range(rows)]


n = int(input())
list1 = input().split()
for i in range(n):
    list1[i] = int(list1[i])
list1.sort()
for i in range(n):
    if(i==0):
        if(list1[i] > 1):
            list1[i] -= 1
    else:
        if(list1[i] < list1[i-1]):
            list1[i] += 1
        elif(list1[i] == list1[i-1]):
            list1[i] += 1
        elif(list1[i] > list1[i-1] + 1):
            list1[i] -= 1
list1.sort()
num = 0
curr= 0
for i in range(n):
    if(list1[i] != curr):
        num += 1
        curr = list1[i]
print(num)


import sys
I = sys.stdin.readline
b = [0]*150003
n = I()
for i in map( int, I().split() ):
    b[ i ] += 1
a = 0
for i in range( 1, 150002 ):
    if b[ i - 1 ] > 0:
        b[ i - 1 ] -= 1
    elif b[ i ] > 0:
        b[ i ] -= 1
    elif b[ i + 1 ] > 0:
        b[ i + 1 ] -= 1
    else:
        a -= 1
    a += 1
print( a )


n = int(input())
l = list(map(int,input().split()))
l.sort()
maksik = -10000000
for i in range(n):
	if l[i] == 1 and maksik < 1:
		maksik = 1
		continue
	else:
		if l[i] - 1 > maksik:
			l[i] -= 1
			maksik = l[i]
		elif l[i] - 1 == maksik:
			maksik = l[i]
		else:
			l[i] += 1
			maksik = l[i]
wyn = 0
for i in range(1, n):
	if l[i] != l[i-1]:
		wyn += 1
print(wyn + 1)

# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
from sys import stdin, stdout
import math
from math import gcd,sqrt

#T = int(input())
N = int(input())
#s = input()
#N,M,Q = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]

add = [-1,0,1]

arr.sort()

freq = {}
res = 0
for i in range(N):
    for j in range(3):
        w = arr[i] + add[j]
        if w>0 and w not in freq:
            freq[w] = 1
            res += 1
            break
            
print(res)

import os, sys

n = int(input())
text = sys.stdin.readline()
a = list(sorted(map(int, text.strip().split())))

m = 150002
lsg = []
while a:
    n = a.pop()
    if n+1 < m:
        m = n+1
        lsg.append(m)
    elif n < m:
        m = n
        lsg.append(m)
    elif n-1 < m:
        m = n-1
        lsg.append(m)

l = len(lsg)
print(l-1 if lsg[-1] == 0 else l)


n = int(input())
ms = sorted(map(int, input().split()))
ws = set()
for i in ms:
	if (i != 1 and i - 1 not in ws):
		ws.add(i - 1)
	elif (i not in ws):
		ws.add(i)
	elif (i + 1 not in ws):
		ws.add(i + 1)
print(len(ws))


n = int(input())
ls = list(map(int, input().split()))

ls.sort()
res = set()
for elt in ls:
    if elt>1 and elt-1 not in res:
        res.add(elt-1)
    elif elt not in res:
        res.add(elt)
    elif elt+1 not in res:
        res.add(elt+1)

print(len(res))


n = int(input())
res = prev = 0
for e in sorted(map(int, input().split())):
    if e < prev: continue
    res += 1
    if e == prev:
        e += 1
    if e - 1 > prev:
        e -= 1
    prev = e
print(res)

ans = int(input())
last = 0
for a in sorted(map(int, input().split())):
    if last > a:
        ans -= 1
    else:
        last = max(a - 1, last + 1)
print(ans)


from sys import stdin
n=int(stdin.readline().strip())

s=list(map(int,stdin.readline().strip().split()))
s.sort()
vis=[False for i in range(150100)]
ans=0
for i in range(n):
    if not vis[s[i]-1] and (s[i]-1)!=0:
        vis[s[i]-1]=True
        ans+=1
    elif not vis[s[i]] :
        ans+=1
        vis[s[i]]=True
    elif not vis[s[i]+1]:
        ans+=1
        vis[s[i]+1]=True
print(ans)
        


import math
n=int(input())
a=list(map(int,input().split()))
a.sort()
hsh=[1]+[0]*(max(a)+1)
for i in a:
    if(hsh[i-1]==0):
        hsh[i-1]=1
    else:
        if(hsh[i]==0):
            hsh[i]=1
        else:
            if(hsh[i+1]==0):
                hsh[i+1]=1
print(hsh.count(1)-1)




N = int(input())
A = list(map(int, input().split()))
A.sort()

pre = 0
ans = 0
for a in A:
    if a > pre+1:
        ans += 1
        pre = a-1
    elif a > pre:
        ans += 1
        pre = a
    elif a == pre:
        ans += 1
        pre = a+1
print(ans)

def main():
    n = int(input())
    arr = list(map(int,input().split()))
    arr.sort()

    nums = set()
    for i in arr:
        if i-1 > 0 and ((i-1) not in nums):
            nums.add(i-1)
        elif i not in nums:
            nums.add(i)
        elif (i+1) not in nums:
            nums.add(i+1)

    print(len(nums))
            


main()


def gns():
    return list(map(int,input().split()))

# t=int(input())
import math
t=1


for i in range(t):
    n=int(input())
    ns=gns()
    ns.sort()
    nd=1

    ans=0
    for i in range(n):
        n=ns[i]
        if n-1>=nd:
            ans+=1
            nd=n
        elif n==nd:
            ans+=1
            nd=n+1
        elif n+1==nd:
            ans+=1
            nd=n+2
        else:
            continue
    print(ans)








import sys
from collections import Counter
import math
input=sys.stdin.readline

n=int(input())
arr=list(map(int,input().split()))

d=Counter(arr)
keys=sorted(d.keys())

res=0
max=0

for i in range(len(keys)):
    while(d[keys[i]]>0):
        if d[keys[i]]>3:
            d[keys[i]]=3
        d[keys[i]]-=1
        if max<keys[i]-1:
            max=keys[i]-1
            res+=1
        elif max==keys[i]-1:
            max=keys[i]
            res+=1
        elif max==keys[i]:
            max=keys[i]+1
            res+=1

print(res)

N = int(input())
A = sorted([int(a) for a in input().split()])

k = 0
ans = 0
for i in range(N):
    if k > A[i]:
        pass
    elif k >= A[i] - 1:
        ans += 1
        k += 1
    else:
        ans += 1
        k = A[i] - 1
print(ans)



from math import gcd

n = int(input())
a = list(map(int, input().split()))
d = {}
for c in a:
	d[c] = d.get(c, 0) + 1
t = sorted(d)
for x in t:
	if x == 1:
		if d[x] > 1:
			d[x + 1] = d.get(x + 1, 0) + 1
	else:
		if d[x] > 2:
			d[x - 1] = d.get(x - 1, 0) + 1
			d[x + 1] = d.get(x + 1, 0) + 1
		elif d[x] == 2:
			if d.get(x - 1, 0) == 0:
				d[x - 1] = 1
			else:
				d[x + 1] = d.get(x + 1, 0) + 1
		if d[x] == 1 and d.get(x - 1, 0) == 0:
			d[x - 1] = 1
			d[x] = 0

ans = 0
for c in d:
	if d[c]:
		ans += 1
print(ans)


n=int(input())
A=sorted(map(int,input().split()))
SET=set()

for a in A:
  if a==1:
    if not(1 in SET):
      SET.add(1)
    else:
      SET.add(2)
      
  else:
    if not(a-1 in SET):
      SET.add(a-1)
      
    elif not (a in SET):
      SET.add(a)
      
    else:
      SET.add(a+1)
      
print(len(SET))

import sys 
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
arr = list(map(int, input().split()))
d = defaultdict(int)

for i in arr:
  d[i] += 1
  if d[i] == 4:
    d[i] = 3

cnt = [0] * 150009

for i, j in sorted(d.items()):
  if j == 3:
    if i-1 > 0:
      cnt[i-1] = 1
    cnt[i] = 1
    cnt[i+1] = 1
  
  elif j == 1:
    #print(cnt[i-1], cnt[i], cnt[i+1])
    if i-1 > 0 and cnt[i-1] == 0:
      cnt[i-1] = 1
      continue
    if cnt[i] == 0:
      cnt[i] = 1
      continue
    if cnt[i+1] == 0:
      cnt[i+1] = 1
      continue

  else:
    cnt2 = 0
    if i-1 > 0 and cnt[i-1] == 0:
      cnt[i-1] = 1
      cnt2 += 1
    if cnt[i] == 0:
      cnt[i] = 1
      cnt2 += 1
    if cnt2 == 2:
      continue
  
    if cnt[i+1] == 0:
      cnt[i+1] = 1
      continue

print(sum(cnt))

import sys
input = sys.stdin.readline
n=int(input())
A=[int(i) for i in input().split()]
A.sort()
ans=1
cur=max(1,A[0]-1)
for i in range(1,n):
  a=A[i]
  if a<cur:
    continue
  elif a==cur:
    ans+=1
    cur+=1
  elif a>cur+1:
    ans+=1
    cur=a-1
  else:
    ans+=1
    cur=a
print(ans)