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: MEDIUM
Tags: Sorting

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
import sys, math, queue
MOD = 998244353
sys.setrecursionlimit(1000000)
n = int(input())
a = list(map(int, input().split()))
f = {}
for ai in a:
	if ai in f:
		f[ai] += 1
	else:
		f[ai] = 1
a = [0 for i in range(150002)]
for i in range(1, 150002):
	if i - 1 in f:
		if f[i - 1] > 0:
			a[i] = 1
			f[i - 1] -= 1
			continue
	if i in f:
		if f[i] > 0:
			a[i] = 1
			f[i] -= 1
			continue
	if i + 1 in f:
		if f[i + 1] > 0:
			a[i] = 1
			f[i + 1] -= 1
			continue
print(sum(a))


n = int(input())
x = list(map(int, input().split()))
x.sort()
if n < 3:
	print(n)
else:
	for i in range(n):
		if x[i] == 1:
			if i != 0 and i != n - 2 and (x[i - 1] == 1) and (x[i + 1] > 1):
				x[i] += 1
			elif x[i + 1] > 1 and x[i - 1] == 1:
				x[i] += 1
		elif i == 0:
			x[i] -= 1
		elif i == n - 1:
			x[i] += 1
		elif x[i - 1] < x[i] - 1 and x[i + 1] < x[i] + 2:
			x[i] -= 1
		elif x[i] == x[i - 1] != x[i + 1]:
			x[i] += 1
	print(len(set(x)))


n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
last_w = float('INF')
k = 0
for i in range(n):
	if a[i] + 1 < last_w:
		last_w = a[i] + 1
		k += 1
		continue
	elif a[i] < last_w:
		last_w = a[i]
		k += 1
		continue
	elif a[i] - 1 < last_w:
		if a[i] - 1 > 0:
			last_w = a[i] - 1
			k += 1
			continue
print(k)


from collections import defaultdict as dd
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
dic = dd(int)
ans = 0
for i in range(len(a)):
	if a[i] - 1 > 0 and a[i] - 1 not in dic:
		dic[a[i] - 1] += 1
		ans += 1
	elif a[i] not in dic:
		dic[a[i]] += 1
		ans += 1
	elif a[i] + 1 not in dic:
		dic[a[i] + 1] += 1
		ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = list()
if a[0] > 1:
	b.append(a[0] - 1)
else:
	b.append(a[0])
for j in range(1, n):
	if a[j] - 1 > b[-1]:
		b.append(a[j] - 1)
	elif a[j] > b[-1]:
		b.append(a[j])
	elif a[j] == b[-1]:
		b.append(a[j] + 1)
print(len(b))


n = int(input())
l = list(map(int, input().split()))[:n]
l.sort()
if l[0] > 1:
	l[0] -= 1
for i in range(1, n):
	if l[i] <= l[i - 1]:
		l[i] += 1
	elif l[i] - 1 > l[i - 1]:
		l[i] -= 1
e = len(set(l))
print(e)


n = int(input())
B = list(map(int, input().split()))
B = sorted(B)
B.extend([15002, 15002, 15002])
A = []
for i in range(n):
	if B[i] != B[i + 3]:
		A.append(B[i])
A.append(150002)
if A[0] > 1:
	A[0] -= 1
for i in range(1, len(A) - 1):
	if A[i] - A[i - 1] > 1:
		A[i] -= 1
		continue
	if A[i] <= A[i - 1]:
		A[i] += 1
ans = len(set(A[:-1]))
print(ans)


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


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)


n = int(input())
a = list(map(int, input().split()))
s = [0 for i in range(150002)]
k = [0 for i in range(150002)]
for i in range(n):
	s[a[i]] += 1
for i in range(1, 150002):
	if i > 1 and s[i] >= 1 and (k[i - 1] + s[i - 1] == 0):
		s[i] -= 1
		k[i - 1] += 1
	if i < 150001:
		if k[i] == 0:
			if s[i] > 1:
				k[i + 1] += s[i] - 1
				s[i] = 1
		else:
			k[i + 1] += s[i]
			s[i] = 0
l = 0
for i in range(1, 150002):
	if k[i] != 0 or s[i] != 0:
		l += 1
print(l)


n = int(input())
elems = [int(elem) for elem in input().split()]
last = float('+inf')
elems = sorted(elems, reverse=True)
ans = 0
for elem in elems:
	if elem + 1 < last:
		ans += 1
		last = elem + 1
	elif elem < last:
		ans += 1
		last = elem
	elif elem - 1 > 0 and elem - 1 < last:
		ans += 1
		last = elem - 1
print(ans)


n = int(input())
l = [int(x) for x in input().split()]
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
(void, matter) = (0, 0)
ans = 0
for i in range(1, max(l) + 2):
	if i not in d:
		if matter > 0:
			matter = 0
			ans += 1
		else:
			void += 1
	else:
		ans += 1
		if d[i] > 1:
			if void > 0:
				ans += 1
				void = 0
				matter += d[i] - 2
			else:
				matter += d[i] - 1
print(ans)


def solve(w):
	w.sort(reverse=True)
	last = w[0] + 1
	res = 1
	for e in w[1:]:
		for d in range(1, -2, -1):
			if 0 < e + d < last:
				last = e + d
				res += 1
				break
	return res
input()
w = list(map(int, input().split()))
print(solve(w))


import math
from collections import Counter
t = 1
for _ in range(t):
	n = int(input())
	ali = list(map(int, input().split()))
	ali.sort()
	c = Counter()
	s = set()
	for i in range(n):
		if ali[i] - 1 not in s and ali[i] - 1 != 0:
			s.add(ali[i] - 1)
		elif ali[i] not in s:
			s.add(ali[i])
		else:
			s.add(ali[i] + 1)
	print(len(s))


n = int(input())
lis = list(map(int, input().split()))
lis.sort()
se = set()
for i in lis:
	if i - 1 not in se and i != 1:
		se.add(i - 1)
	elif i not in se:
		se.add(i)
	elif i + 1 not in se:
		se.add(i + 1)
print(len(se))


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
n = int(cin())
a = list(map(int, cin().split()))
if n == 1:
	cout('1')
	exit(0)
a.sort()
count = n
if a[0] > 1:
	a[0] -= 1
for i in range(1, n):
	if a[i] == a[i - 1]:
		a[i] += 1
	elif a[i] < a[i - 1]:
		a[i] = a[i - 1]
		count -= 1
	elif i + 1 < n:
		if a[i] > a[i - 1] and a[i] == a[i + 1]:
			if a[i] - 1 > a[i - 1]:
				a[i] -= 1
		elif a[i] > a[i - 1] and a[i] < a[i + 1]:
			if a[i] - 1 > a[i - 1]:
				a[i] -= 1
		else:
			count -= 1
cout(str(count))


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

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

def getStr():
	return input().strip()
N = getInt()
A = getArr()
A.sort()
komanda = 1
m1 = max(1, A[0] - 1)
m2 = A[0] + 1
for i in range(1, N):
	if A[i] < m1:
		continue
	m1 = max(m1 + 1, A[i] - 1)
	komanda += 1
print(komanda)


n = int(input())
a_list = sorted(map(int, input().split(' ')))
before = a_list[0]
if before >= 2:
	before -= 1
count = 1
for a in a_list[1:]:
	if before >= a + 1:
		continue
	elif before == a:
		count += 1
		before = a + 1
	elif before == a - 1:
		count += 1
		before = a
	else:
		count += 1
		before = a - 1
print(count)


n = int(input())
aa = list(map(int, input().split()))
aa.sort()
count = n
current = 0
for a in aa:
	if a > current + 1:
		current = a - 1
	elif a < current:
		count -= 1
	else:
		current += 1
print(count)


from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
m = max(A)
ans = 0
L = [False] * (m + 2)
if C[1] >= 1:
	L[1] = True
	if C[1] >= 2:
		L[2] = True
for i in range(2, m + 1):
	if C[i] == 0:
		continue
	if C[i] == 1:
		if not L[i - 1]:
			L[i - 1] = True
		elif not L[i]:
			L[i] = True
		else:
			L[i + 1] = True
	elif C[i] == 2:
		L[i] = True
		if not L[i - 1]:
			L[i - 1] = True
		else:
			L[i + 1] = True
	elif C[i] >= 3:
		L[i - 1] = True
		L[i] = True
		L[i + 1] = True
print(sum(L))


size = int(input())
weights = [int(el) for el in input().split()]
weights.sort()
weightsSet = set()
i = size - 1
while i > -1:
	if not weights[i] + 1 in weightsSet:
		weightsSet.add(weights[i] + 1)
	elif not weights[i] in weightsSet:
		weightsSet.add(weights[i])
	elif weights[i] - 1 > 0 and (not weights[i] - 1 in weightsSet):
		weightsSet.add(weights[i] - 1)
	i -= 1
print(len(weightsSet))


n = int(input())
y = list(map(int, input().split()))
y = sorted(y)
y[n - 1] += 1
i = n - 2
while i >= 0:
	if y[i] + 1 == y[i + 1]:
		i -= 1
	elif y[i] + 1 < y[i + 1]:
		y[i] += 1
		i -= 1
	elif y[i] == y[i + 1]:
		if y[i] != 1:
			y[i] -= 1
		else:
			y.pop(i)
		i -= 1
	elif y[i] > y[i + 1]:
		y.pop(i)
		i -= 1
print(len(y))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
vals = list(map(int, input().split()))
dict1 = {}
for s in range(n):
	if not vals[s] in dict1:
		dict1[vals[s]] = 1
	else:
		dict1[vals[s]] += 1
team = set([])
keys = [x for x in dict1.keys()]
keys.sort()
for s in keys:
	count = dict1[s]
	if dict1[s] == 1 or dict1[s] == 2:
		if not max(1, s - 1) in team and count > 0:
			team.add(max(1, s - 1))
			count -= 1
		if not s in team and count > 0:
			team.add(s)
			count -= 1
		if not s + 1 in team and count > 0:
			team.add(s + 1)
			count -= 1
	else:
		team.add(max(1, s - 1))
		team.add(s)
		team.add(s + 1)
print(len(team))


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)


n = int(input())
a = list(map(int, input().split()))
a.sort()
p = a[-1] + 1
r = 1
for i in range(len(a) - 2, -1, -1):
	for j in range(1, -2, -1):
		x = a[i] + j
		if x < p and x > 0:
			p = x
			r += 1
			break
print(r)


R = lambda : map(int, input().split())
n = int(input())
L = sorted(R())
f = [0] * (L[n - 1] + 2)
for i in L:
	if f[i - 1] == 0 and i - 1 > 0:
		f[i - 1] = 1
	elif f[i] == 0:
		f[i] = 1
	elif f[i + 1] == 0:
		f[i + 1] = 1
print(f[1:].count(1))


def boxers(n, lst):
	if lst[0] > 1:
		lst[0] -= 1
	result = 1
	for i in range(1, n):
		if lst[i] > lst[i - 1] + 1:
			lst[i] -= 1
			result += 1
		elif lst[i] == lst[i - 1]:
			lst[i] += 1
			result += 1
		elif lst[i] == lst[i - 1] - 1:
			lst[i] += 1
		else:
			result += 1
	return result
m = int(input())
a = [int(j) for j in input().split()]
print(boxers(m, sorted(a)))


n = int(input())
powers = input().split()
for i in range(n):
	powers[i] = int(powers[i])
powers.sort()
how_many = 0
which_powers = set()
for j in range(n):
	now_power = powers[j]
	if now_power not in which_powers:
		if now_power - 1 not in which_powers and now_power > 1:
			how_many += 1
			which_powers.add(now_power - 1)
		else:
			how_many += 1
			which_powers.add(now_power)
	elif now_power + 1 not in which_powers:
		how_many += 1
		which_powers.add(now_power + 1)
print(how_many)


import math
n = int(input())
a = sorted(list(map(int, input().strip().split())), reverse=True)
last = math.inf
c = 0
for i in range(n):
	if last > a[i] + 1:
		last = a[i] + 1
		if last > 0:
			c = c + 1
	elif last > a[i]:
		last = a[i]
		if last > 0:
			c = c + 1
	elif last > a[i] - 1:
		last = a[i] - 1
		if last > 0:
			c = c + 1
print(c)


n = int(input())
a = list(map(int, input().split()))
m = max(a)
x = [0] * (m + 1)
y = [0] * (m + 2)
for i in range(n):
	x[a[i]] += 1
if x[1] != 0:
	if x[1] == 1:
		y[1] = 1
	else:
		y[1] = 1
		y[2] = 1
for i in range(2, m + 1):
	if x[i] != 0:
		if x[i] == 1:
			if y[i - 1] == 0:
				y[i - 1] = 1
			elif y[i] == 0:
				y[i] = 1
			else:
				y[i + 1] = 1
		elif x[i] == 2:
			if y[i - 1] == 1:
				y[i] = 1
				y[i + 1] = 1
			elif y[i] == 1:
				y[i - 1] = 1
				y[i + 1] = 1
			elif y[i + 1] == 1:
				y[i - 1] = 1
				y[i] = 1
			else:
				y[i - 1] = 1
				y[i] = 1
		else:
			y[i - 1] = 1
			y[i] = 1
			y[i + 1] = 1
print(sum(y))


number_of_boxers = int(input())
boxers_weight = input().split()
boxers_weight = [int(x) for x in boxers_weight]
boxers_weight = sorted(boxers_weight, reverse=True)
maximum = 150002
team = []
for number in boxers_weight:
	if number + 1 < maximum:
		team.append(number + 1)
		maximum = number + 1
	elif number < maximum:
		team.append(number)
		maximum = number
	elif number - 1 < maximum:
		team.append(number - 1)
		maximum = number - 1
final_team = [x for x in team if x != 0]
print(len(final_team))


n = int(input())
a = list(map(int, input().split()))
a.sort()
hash = [0] * 150002
hash[0] = 90
if a[0] == 1:
	hash[1] += 1
else:
	hash[a[0] - 1] += 1
for i in range(1, n):
	if hash[a[i] - 1] == 0:
		hash[a[i] - 1] += 1
	elif hash[a[i]] == 0:
		hash[a[i]] += 1
	elif hash[a[i] + 1] == 0:
		hash[a[i] + 1] += 1
ans = 0
for i in range(len(hash)):
	if hash[i] != 0:
		ans += 1
print(ans - 1)


from sys import stdin
input = stdin.readline
n = int(input())
a = sorted(list(map(int, input().split())))
s = set()
for i in a:
	for j in range(-1, 2):
		x = max(1, i + j)
		if x not in s:
			s.add(x)
			break
print(len(s))


n = int(input())
a = list(map(int, input().split()))
a.sort()
count = 1
cur = a[0]
if a[0] != 1:
	cur -= 1
for i in range(1, n):
	if a[i] == cur:
		count += 1
		cur += 1
	elif a[i] > cur:
		count += 1
		if cur + 1 < a[i]:
			cur = a[i] - 1
		else:
			cur = a[i]
print(count)


n = int(input())
l = [-1, -1, -1]
l += list(map(int, input().split()))
l.sort()
f = -1
f1 = -1
ans = 0
for i in range(3, n + 3):
	if l[i] - 1 != 0 and l[i] - 1 != l[i - 1] and (l[i] - 1 != l[i - 2]) and (l[i] - 1 != l[i - 3]):
		ans += 1
		f1 = min(f, l[i] - 1)
		f = max(f, l[i] - 1)
		l[i] -= 1
	elif l[i - 1] != l[i] and l[i] != l[i - 2] and (l[i] != l[i - 3]):
		f1 = f
		ans += 1
		f = l[i]
	elif l[i] + 1 != l[i - 1] and l[i] + 1 != l[i - 2] and (l[i] + 1 != l[i - 3]):
		f1 = f
		ans += 1
		f = l[i] + 1
		l[i] += 1
	else:
		(l[i - 2], l[i - 1], l[i]) = (l[i - 3], l[i - 2], l[i - 1])
print(ans)


from math import *

def nextInt():
	return int(input())

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

def solve():
	cnt = [0] * 150001
	n = nextInt()
	a = nextInts()
	for i in a:
		cnt[i] += 1
	lst = 0
	ans = 0
	for i in range(1, 150001):
		for j in range(cnt[i]):
			res = max(i - 1, lst + 1)
			if res > i + 1:
				break
			lst = res
			ans += 1
	return ans
print(solve())


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
n = ii()
d = sorted(li())
s = set()
for i in d:
	if i > 1 and i - 1 not in s:
		s.add(i - 1)
	elif i not in s:
		s.add(i)
	elif i + 1 not in s:
		s.add(i + 1)
print(len(s))


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())
l = list(sorted(map(int, input().split())))
s = set()
for i in l:
	if i - 1 > 0 and i - 1 not in s:
		s.add(i - 1)
	elif i not in s:
		s.add(i)
	elif i + 1 not in s:
		s.add(i + 1)
print(len(s))


n = int(input())
L = [int(i) for i in input().strip().split()]
L.sort()
s = set()
for i in L:
	if i > 1 and i - 1 not in s:
		s.add(i - 1)
	elif i not in s:
		s.add(i)
	elif i + 1 not in s:
		s.add(i + 1)
print(len(s))


from sys import stdin, stdout
import math
from math import gcd, sqrt
N = int(input())
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)


n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
if len(A) == len(set(A)):
	print(n)
	exit()
S = set()
for a in A:
	if a != 1:
		if a + 1 not in S:
			S.add(a + 1)
		elif a not in S:
			S.add(a)
		elif a - 1 not in S:
			S.add(a - 1)
		else:
			pass
	elif a + 1 not in S:
		S.add(a + 1)
	elif a not in S:
		S.add(a)
	else:
		pass
print(len(S))


n = int(input())
l = list(map(int, input().split()))
l.sort()
m = set()
for i in l:
	if i - 1 > 0 and i - 1 not in m:
		m.add(i - 1)
	elif i not in m:
		m.add(i)
	elif i + 1 not in m:
		m.add(i + 1)
print(len(m))


n = int(input())
a = sorted(list(map(int, input().split())))
lst = 0
cnt = 0
for i in a:
	if i - 1 > lst:
		lst = i - 1
		cnt += 1
	elif i > lst:
		lst = i
		cnt += 1
	elif i + 1 > lst:
		lst = i + 1
		cnt += 1
print(cnt)


n = int(input())
originalWeights = input()
originalWeights = originalWeights.split(' ')
originalWeights = [int(w) for w in originalWeights]
originalWeights.sort()
finalWeights = []
for w in originalWeights:
	if w == 1:
		wLower = 1
		wUpper = w + 1
	elif w == 150001:
		wLower = w - 1
		wUpper = 150001
	else:
		wLower = w - 1
		wUpper = w + 1
	if len(finalWeights) == 0:
		finalWeights.append(wLower)
	else:
		lastWeight = finalWeights[len(finalWeights) - 1]
		if wLower > lastWeight:
			finalWeights.append(wLower)
		elif w > lastWeight:
			finalWeights.append(w)
		elif wUpper > lastWeight:
			finalWeights.append(wUpper)
print(len(finalWeights))


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
lst = a[0] + 2
ans = 0
for i in a:
	cur = -1
	for j in range(1, -2, -1):
		if i + j > 0 and i + j < lst:
			cur = i + j
			break
	if cur == -1:
		continue
	ans += 1
	lst = cur
print(ans)


n = int(input())
x = [int(y) for y in input().split(' ')]
people = [0] * 150003
team = [0] * 150003
for i in x:
	people[i] += 1
for i in range(1, 150002, 1):
	if people[i - 1] > 0:
		people[i - 1] -= 1
		team[i] = 1
	elif people[i] > 0:
		people[i] -= 1
		team[i] = 1
	elif people[i + 1] > 0:
		people[i + 1] -= 1
		team[i] = 1
print(sum(team))


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()


import collections, heapq, bisect, math

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def solve(A):
	A.sort()
	out = 0
	last = -1
	for a in A:
		if a == 1 and last < 1:
			last = 1
			out += 1
		elif last < a - 1:
			last = a - 1
			out += 1
		elif last == a - 1:
			last = a
			out += 1
		elif last == a:
			last = a + 1
			out += 1
	return out
q = 1
tests = []
for test in range(int(q)):
	n = input()
	tests.append([int(p) for p in input().split(' ')])
for A in tests:
	print(solve(A))


import sys
input = sys.stdin.readline
from math import gcd, sqrt
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
ans = 1
if l[0] != 1:
	l[0] -= 1
for i in range(1, n):
	if l[i - 1] > l[i]:
		l[i] += 1
		continue
	elif l[i - 1] == l[i]:
		l[i] += 1
		ans += 1
		continue
	elif l[i - 1] == l[i] - 1:
		ans += 1
		continue
	else:
		l[i] -= 1
		ans += 1
		continue
print(ans)


def main():
	count = int(input())
	boxers = [int(i) for i in input().split()]
	boxers.sort()
	team = []
	for i in range(count):
		weight = boxers[i]
		if i == 0:
			weight = weight if weight == 1 else weight - 1
			team.append(weight)
			continue
		last = team[len(team) - 1]
		if last == weight + 1:
			continue
		if last == weight:
			team.append(weight + 1)
			continue
		if last == weight - 1:
			team.append(weight)
			continue
		team.append(weight - 1)
	print(len(team))
main()


from sys import stdin, stdout
input = stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
b = {}
a.sort()
for i in a:
	b[i] = 0
	if i - 1:
		b[i - 1] = 0
	b[i + 1] = 0
for i in a:
	if i == 1:
		if b[i] == 0:
			b[i] += 1
		else:
			b[i + 1] += 1
	elif b[i - 1] == 0:
		b[i - 1] += 1
	elif b[i] == 0:
		b[i] += 1
	else:
		b[i + 1] += 1
res = 0
for i in b.values():
	res += i > 0
print(res)


def solve(n, ar):
	ar.sort()
	ar.reverse()
	lst = ar[0] + 2
	ans = 0
	for i in range(n):
		cur = -1
		for dx in range(1, -2, -1):
			if ar[i] + dx > 0 and ar[i] + dx < lst:
				cur = ar[i] + dx
				break
		if cur == -1:
			continue
		ans += 1
		lst = cur
	print(ans)
n = int(input())
ar = list(map(int, input().split()))
solve(n, ar)


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())
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
	elif 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)


n = int(input())
ar = list(map(int, input().split()))
ar.sort()
se = set({})
ans = 0
for i in range(n):
	if ar[i] == 1:
		if not ar[i] in se:
			ans += 1
			se.add(ar[i])
		elif not ar[i] + 1 in se:
			ans += 1
			se.add(ar[i] + 1)
	elif not ar[i] - 1 in se:
		ans += 1
		se.add(ar[i] - 1)
	elif not ar[i] in se:
		ans += 1
		se.add(ar[i])
	elif not ar[i] + 1 in se:
		ans += 1
		se.add(ar[i] + 1)
print(ans)


n = int(input())
w = list(map(int, input().split()))
w.sort()
uniq = [0]
for elem in w:
	if elem != 1 and elem - 1 > uniq[len(uniq) - 1]:
		uniq.append(elem - 1)
	elif elem > uniq[len(uniq) - 1]:
		uniq.append(elem)
	elif elem + 1 > uniq[len(uniq) - 1]:
		uniq.append(elem + 1)
print(len(uniq) - 1)


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
l = li()
l.sort(reverse=True)
a = l[0] + 2
ans = 0
for i in range(n):
	c = -1
	for j in range(1, -2, -1):
		if l[i] + j >= 1 and l[i] + j < a:
			c = l[i] + j
			break
	if c == -1:
		continue
	else:
		ans += 1
	a = c
print(ans)


n = int(input())
(*l,) = map(int, input().split())
l.sort()
s = set()
for i in l:
	if i > 1 and i - 1 not in s:
		s.add(i - 1)
	elif i not in s:
		s.add(i)
	elif i + 1 not in s:
		s.add(i + 1)
print(len(s))


n = int(input())
arr = list(map(int, input().split()))
last = 0
for i in sorted(arr):
	if last > i:
		n -= 1
	else:
		last = max(i - 1, last + 1)
print(n)


n = int(input())
spaces = [0] * 150002
a = list(map(int, input().split()))
a.sort()
cnt = 0
for x in a:
	for i in range(x - 1, x + 2):
		if i > 0:
			if spaces[i] == 0:
				spaces[i] = 1
				cnt += 1
				break
print(cnt)


n = int(input())
w = list(map(int, input().split()))
w.sort()
(ans, i, back) = (0, 0, True)
while i < n:
	st = i
	while i < n - 1 and w[i + 1] - w[i] < 2:
		i += 1
	ans += w[i] - w[st] + 1
	ext = i - st + 1 - (w[i] - w[st] + 1)
	if ext > 0 and w[st] > 1 and (st == 0 or w[st] - w[st - 1] > 1) and back:
		ans += 1
		ext -= 1
	back = True
	if ext > 0 and w[i] < 150001 and (i == n - 1 or w[i + 1] - w[i] > 1):
		ans += 1
		ext -= 1
		if i < n - 1 and w[i + 1] - w[i] == 2:
			back = False
	i += 1
print(ans)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a1 = Counter(a)
s = []
a1k = sorted(list(a1.keys()))
la1k = len(a1k)
for i in range(la1k):
	key = a1k[i]
	if a1[key] == 1:
		if s and s[-1] < key - 1 and (key - 1 > 0):
			s.append(key - 1)
		elif s and s[-1] == key - 1:
			s.append(key)
		elif s and s[-1] == key:
			s.append(key + 1)
		if not s:
			if key - 1 > 0:
				s.append(key - 1)
			else:
				s.append(key)
	elif a1[key] == 2:
		if s and s[-1] < key - 1 and (key > 0):
			s.append(key - 1)
			s.append(key)
		elif s and s[-1] == key - 1:
			s.append(key)
			s.append(key + 1)
		elif s and s[-1] == key:
			s.append(key + 1)
		if not s:
			if key - 1 > 0:
				s.append(key - 1)
				s.append(key)
			else:
				s.append(key)
				s.append(key + 1)
	else:
		if s and s[-1] < key - 1 and (key > 0):
			s.append(key - 1)
			s.append(key)
			s.append(key + 1)
		elif s and s[-1] == key - 1:
			s.append(key)
			s.append(key + 1)
		elif s and s[-1] == key:
			s.append(key + 1)
		if not s:
			if key - 1 > 0:
				s.append(key - 1)
				s.append(key)
				s.append(key + 1)
			else:
				s.append(key)
				s.append(key + 1)
print(len(s))


from sys import stdin
from collections import defaultdict
n = int(stdin.readline().strip())
a = [int(i) for i in stdin.readline().strip().split()]
a.sort()

def solve(a):
	nums = set()
	for e in a:
		if e - 1 > 0 and e - 1 not in nums:
			nums.add(e - 1)
		elif e not in nums:
			nums.add(e)
		elif e + 1 not in nums:
			nums.add(e + 1)
	return len(nums)
print(solve(a))


counter = 0
n = int(input())
avail = [0 for i in range(150002)]
avail[0] = 1
lists = []
li = input()
list_1 = li.split()
for i in range(len(list_1)):
	lists.append(int(list_1[i]))
lists.sort()
for i in range(0, n):
	number = int(lists[i])
	if number == 1:
		if avail[number] == 0:
			avail[number] = 1
			counter += 1
		elif avail[number + 1] == 0:
			avail[number + 1] = 1
			counter += 1
	elif avail[number - 1] == 0:
		avail[number - 1] = 1
		counter += 1
	elif avail[number] == 0:
		avail[number] = 1
		counter += 1
	elif avail[number + 1] == 0:
		avail[number + 1] = 1
		counter += 1
print(counter)


length = int(input())
arr = list(map(int, input().split(' ')))
arr.insert(0, 0)
arr.sort()
team = 0
for i in range(1, length + 1):
	if arr[i - 1] == arr[i]:
		team += 1
		arr[i] += 1
	elif arr[i - 1] == arr[i] - 1:
		team += 1
	elif arr[i - 1] < arr[i] - 1:
		team += 1
		arr[i] -= 1
	elif arr[i - 1] - 1 == arr[i]:
		arr[i] += 1
print(team)


n = int(input())
lst = sorted(list(map(int, input().split())))
a = set()
for i in lst:
	if i != 1 and i - 1 not in a:
		a.add(i - 1)
	elif i not in a:
		a.add(i)
	elif i + 1 not in a:
		a.add(i + 1)
	else:
		pass
print(len(a))


length = int(input())
nums = list(map(int, input().split()))
dic = {}
for i in nums:
	if i in dic:
		dic[i] += 1
	else:
		dic.setdefault(i, 1)
box = [[x, dic[x]] for x in dic.keys()]
box.sort()
ans = set()
for i in range(len(box)):
	if box[i][0] == 1:
		if box[i][1] > 1:
			ans.add(1)
			ans.add(2)
		else:
			ans.add(1)
	else:
		if box[i][0] - 1 not in ans and box[i][1] > 0:
			ans.add(box[i][0] - 1)
			box[i][1] -= 1
		if box[i][0] not in ans and box[i][1] > 0:
			ans.add(box[i][0])
			box[i][1] -= 1
		if box[i][0] + 1 not in ans and box[i][1] > 0:
			ans.add(box[i][0] + 1)
print(len(ans))


n = int(input())
arr = [int(x) for x in input().strip().split()]
arr.sort()
lastAdd = 0
ans = 0
for x in arr:
	if lastAdd >= x:
		if lastAdd < x + 1:
			lastAdd = x + 1
			ans += 1
	elif x - 1 > 0 and lastAdd < x - 1:
		lastAdd = x - 1
		ans += 1
	else:
		lastAdd = x
		ans += 1
print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def bs(a, l, h, x):
	while l < h:
		mid = (l + h) // 2
		if a[mid] == x:
			return mid
		if a[mid] < x:
			l = mid + 1
		else:
			h = mid
	return l

def sieve(a):
	for i in range(3, 10 ** 6 + 1, 2):
		a[i] = 1
	for i in range(3, 10 ** 6 + 1, 2):
		for j in range(i * i, 10 ** 6 + 1, i):
			a[j] = 0
	a[2] = 1
	return a

def solve():
	n = int(inp())
	a = lis()
	a = sorted(a)
	cnt = [0] * 150002
	for i in range(0, n):
		if a[i] == 1:
			if cnt[1] == 0:
				cnt[1] += 1
			elif cnt[2] == 0:
				cnt[2] += 1
		elif cnt[a[i] - 1] == 0:
			cnt[a[i] - 1] += 1
		elif cnt[a[i]] == 0:
			cnt[a[i]] += 1
		elif cnt[a[i] + 1] == 0:
			cnt[a[i] + 1] += 1
	ans = 0
	for i in range(1, 150002):
		if cnt[i] > 0:
			ans += 1
	print(ans)
testcase(1)


n = int(input())
a = [int(ele) for ele in input().split()]
a.sort()
a.reverse()
i = 0
count = 0
while i < n:
	if i == 0:
		lst = a[i] + 1
		count += 1
	elif a[i] + 1 < lst and a[i] + 1 > 0:
		lst = a[i] + 1
		count += 1
	elif a[i] < lst and a[i] > 0:
		lst = a[i]
		count += 1
	elif a[i] - 1 < lst and a[i] - 1 > 0:
		lst = a[i] - 1
		count += 1
	i += 1
print(count)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if not True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	sa = set()
	for i in range(n):
		if a[i] - 1 not in sa and a[i] - 1:
			sa.add(a[i] - 1)
		elif a[i] not in sa and a[i]:
			sa.add(a[i])
		else:
			sa.add(a[i] + 1)
	print(len(sa))


n = int(input())
ls = list(map(int, input().split()))
ls.sort()
boxerset = set()
for i in ls:
	if i - 1 not in boxerset and i != 1:
		boxerset.add(i - 1)
	elif i not in boxerset:
		boxerset.add(i)
	elif i + 1 not in boxerset:
		boxerset.add(i + 1)
	else:
		continue
print(len(boxerset))


a = int(input())
z = list(map(int, input().split()))
on = sorted(z, reverse=True)
bn = sorted(z)
i = 1
bn[0] = max(bn[0] - 1, 1)
while i < len(bn):
	if bn[i] > bn[i - 1]:
		if bn[i] > bn[i - 1] + 1:
			bn[i] = max(bn[i] - 1, 1)
		i += 1
		continue
	elif bn[i] == bn[i - 1]:
		bn[i] = min(150001, bn[i - 1] + 1)
	else:
		temp = bn[i]
		bn[i] = bn[i - 1]
		bn[i - 1] = temp
	i += 1
i = 1
on[0] = min(on[0] + 1, 150001)
while i < len(on):
	if on[i] < on[i - 1]:
		if on[i] < on[i - 1] - 1:
			on[i] = min(on[i] + 1, 150001)
		i += 1
		continue
	elif on[i] == on[i - 1]:
		on[i] = max(1, on[i - 1] - 1)
	else:
		temp = on[i]
		on[i] = on[i - 1]
		on[i - 1] = temp
	i += 1
kama = len(set(bn))
mana = len(set(on))
print(max(mana, kama))


n = int(input())
ls = list(map(int, input().split()))
ls.sort()
low = 0
count = 0
for l in ls:
	if l - 1 > low:
		low = l - 1
		count += 1
	elif l > low:
		low = l
		count += 1
	elif l + 1 > low:
		low = l + 1
		count += 1
print(count)


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)


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
n = int(input())
s = set([])
a = listin()
a.sort()
for i in a:
	if i == 1:
		if i not in s:
			s.add(i)
		else:
			s.add(i + 1)
	elif i - 1 not in s:
		s.add(i - 1)
	elif i not in s:
		s.add(i)
	else:
		s.add(i + 1)
print(len(s))


import sys
(mod, MOD) = (1000000007, 998244353)
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd, log10, atan, tan

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
myset = set()
Arr.sort()
for i in Arr:
	if i == 1:
		if 1 not in myset:
			myset.add(1)
		else:
			myset.add(2)
	elif i - 1 not in myset:
		myset.add(i - 1)
	elif i not in myset:
		myset.add(i)
	else:
		myset.add(i + 1)
print(len(myset))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24
from decimal import *

def solve():
	n = N()
	ar = lis()
	ar.sort(reverse=True)
	ma = 9999999999
	c = 0
	for i in range(n):
		if ar[i] + 1 < ma:
			c += 1
			ma = ar[i] + 1
			continue
		if ar[i] < ma:
			c += 1
			ma = ar[i]
			continue
		if ar[i] - 1 < ma and ar[i] - 1 > 0:
			c += 1
			ma = ar[i] - 1
			continue
	print(c)
solve()


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
s = set()
for i in a:
	if i - 1 > 0 and i - 1 not in s:
		s.add(i - 1)
	elif i not in s:
		s.add(i)
	else:
		s.add(i + 1)
print(len(s))


n = int(input())
a = sorted(map(int, input().split()))
arr = [0] * 150002
for m in a:
	if m > 1 and arr[m - 1] == 0:
		arr[m - 1] = 1
	elif arr[m] == 0:
		arr[m] = 1
	elif arr[m + 1] == 0:
		arr[m + 1] = 1
print(sum(arr))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mx = 0
	ans = 0
	for x in a:
		if x - 1 > mx:
			ans += 1
			mx = x - 1
		elif x > mx:
			ans += 1
			mx = x
		elif x + 1 > mx:
			ans += 1
			mx = x + 1
	print(ans)
main()


from sys import stdin, stdout
INF = 100000000000.0

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()
from collections import defaultdict
n = get_int()
a = get_array()
s = set()
a.sort()
op = [-1, 0, 1]
for i in a:
	for c in op:
		new = i + c
		if new > 0:
			if new not in s:
				s.add(new)
				break
print(len(s))


no_of_boxer = input()
boxer_list = list(map(int, input().split()))
boxer_list.sort()
boxer_set = set()
for i in boxer_list:
	if i - 1 not in boxer_set and i != 1:
		boxer_set.add(i - 1)
	elif i not in boxer_set:
		boxer_set.add(i)
	elif i + 1 not in boxer_set:
		boxer_set.add(i + 1)
	else:
		continue
print(len(boxer_set))


import math

class Read:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	a = Read.list_int()
	a.sort()
	res = 0
	m = 0
	for i in a:
		if i > m:
			if i - m == 1:
				m = i
			else:
				m = i - 1
			res += 1
		elif i == m:
			m = i + 1
			res += 1
	print(res)
query_count = 1
for j in range(query_count):
	solve()


import math
from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
li = lambda : list(map(int, input().split()))
n = int(input())
a = li()
a.sort(reverse=True)
a[0] += 1
for i in range(1, n):
	if a[i] < a[i - 1] and a[i - 1] - a[i] != 1:
		a[i] += 1
	elif a[i] == a[i - 1] and a[i] != 1:
		a[i] -= 1
	elif a[i] > a[i - 1] and a[i] != 0:
		a[i] -= 1
print(len(set(a)))


n = int(input())
last = 0
a = [0] * n
a = input().split()
for i in range(n):
	a[i] = int(a[i])
a.sort()
for c in a:
	if last > c:
		n -= 1
	else:
		last = max(last + 1, c - 1)
print(n)


n = int(input())
A = list(map(int, input().split()))
A.sort()
if A[0] != 1:
	A[0] -= 1
A[-1] += 1
for i in range(1, n - 1):
	if A[i] - 1 > A[i - 1] and A[i] != 1:
		A[i] -= 1
	elif A[i] == A[i - 1] and A[i] != A[i + 1]:
		A[i] += 1
print(len(set(A)))


x = int(input())
s = sorted(list(map(int, input().split())))
z = [0 for n in range(10 ** 7)]
l = 0
for n in s:
	if n >= 2 and z[n - 1] == 0:
		z[n - 1] = 1
		l += 1
	elif z[n] == 0:
		z[n] = 1
		l += 1
	elif z[n + 1] == 0:
		z[n + 1] = 1
		l += 1
print(l)


from math import *
n = int(input())
l = list(map(int, input().split()))
d = dict()
l1 = l[:]
l.sort(reverse=True)
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
c = [0 for i in range(n)]
for i in range(n):
	if l[i] + 1 not in d or d[l[i] + 1] == 0:
		d[l[i]] -= 1
		l[i] += 1
		d[l[i]] = 1
	elif d[l[i]] == 1:
		continue
	elif l[i] > 1:
		d[l[i]] -= 1
		l[i] -= 1
		if l[i] in d:
			d[l[i]] += 1
		else:
			d[l[i]] = 1
s = len(set(l))
print(s)


n = int(input())
a = sorted(list(map(int, input().split())))
last1 = ans = 0
for q in a:
	if q - 1 > last1:
		ans += 1
		last1 = q - 1
	elif q > last1:
		ans += 1
		last1 = q
	elif q == last1:
		ans += 1
		last1 = q + 1
print(ans)


n = int(input())
a = sorted([int(x) for x in input().split()])
s = set()
for i in a:
	if i > 1 and i - 1 not in s:
		s.add(i - 1)
	elif i not in s:
		s.add(i)
	elif i + 1 not in s:
		s.add(i + 1)
print(len(s))


n = int(input())
arr = sorted([int(s) for s in input().split()])
ans = [0] * 1500000
ans[0] = 1
for i in arr:
	if ans[i - 1] == 0:
		ans[i - 1] = 1
		continue
	if ans[i] == 0:
		ans[i] = 1
		continue
	if ans[i + 1] == 0:
		ans[i + 1] = 1
print(sum(ans) - 1)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = sorted(il())
s = set()
for i in l:
	if i > 1 and (not i - 1 in s):
		s.add(i - 1)
	elif not i in s:
		s.add(i)
	elif not i + 1 in s:
		s.add(i + 1)
print(len(s))


from collections import Counter
n = int(input())
a = Counter([*map(int, input().split())])
b = sorted(a.keys())
b.reverse()
nums = [b[0] + 2]
for i in b:
	j = 1
	while a[i] > 0 and j > -2:
		if nums[-1] > i + j and i + j > 0:
			nums.append(i + j)
			a[i] -= 1
		j -= 1
print(len(nums) - 1)


import sys
import math
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
freq = [0] * 150002
arr.sort()
for i in range(n):
	freq[arr[i]] += 1
sorty = list()
sum = 0
st = 1
i = 1
while i < len(freq):
	if freq[i] != 0:
		sum += freq[i]
	else:
		if sum - (i - st) == 1:
			if st == 1:
				freq[i] = 1
			elif freq[st - 1] == 0:
				freq[st - 1] = 1
			else:
				freq[i] = 1
		elif sum - (i - st) >= 2:
			freq[st - 1] = 1
			freq[i] = 1
		sum = 0
		st = i + 1
	i += 1
ans = 0
for i in range(1, len(freq)):
	if freq[i] > 0:
		ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
s = sorted(a)
s[0] = max(1, s[0] - 1)
n = 1
k = s[0]
for i in range(1, len(s)):
	if s[i] > k:
		k = max(s[i] - 1, k + 1)
		n += 1
	elif s[i] == k:
		k = s[i] + 1
		n += 1
	elif s[i] < k:
		continue
print(n)


import bisect
from itertools import accumulate, count
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	for i in range(2, len(primes)):
		if primes[i] == True:
			prime.append(i)
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return fac

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)

def NcR(n, r):
	p = 1
	k = 1
	if n - r < r:
		r = n - r
	if r != 0:
		while r:
			p *= n
			k *= r
			m = math.gcd(p, k)
			p //= m
			k //= m
			n -= 1
			r -= 1
	else:
		p = 1
	return p

def Log2(x):
	if x == 0:
		return False
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
n = int(input())
a = sorted(list(map(int, input().split())))
s = set()
a = a[::-1]
for i in range(0, len(a)):
	if a[i] + 1 not in s:
		s.add(a[i] + 1)
	elif a[i] not in s:
		s.add(a[i])
	else:
		s.add(max(a[i] - 1, 1))
print(len(s))


import sys, math, bisect
from collections import defaultdict
M = 10 ** 9 + 7

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def factor(n):
	potentional_p = 3
	itog_list = {}
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			if n in itog_list:
				itog_list[n] += 1
			else:
				itog_list[n] = 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			if potentional_p in itog_list:
				itog_list[potentional_p] += 1
			else:
				itog_list[potentional_p] = 1
		potentional_p += 2
	return itog_list
n = int(input())
a = list(map(int, input().split()))
a.sort()
temp = []
for x in a:
	if x == 1:
		temp.append([1, 2])
	else:
		temp.append([x - 1, x, x + 1])
cval = temp[0][0]
res = 1
for i in range(1, len(temp)):
	for x in temp[i]:
		if x > cval:
			res += 1
			cval = x
			break
print(res)


n = int(input())
a = list(map(int, input().split()))
a.sort()
cnt = 0
team = [a[0] - 1] if a[0] > 1 else [a[0]]
for x in a[1:]:
	if x - 1 > team[-1]:
		team.append(x - 1)
	elif x > team[-1]:
		team.append(x)
	elif x + 1 > team[-1]:
		team.append(x + 1)
print(len(team))


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
a = sorted(a)
for i in a:
	if i == 1:
		if d[i] == 0:
			d[i] = 1
		elif d[i + 1] == 0:
			d[i + 1] = 1
	elif d[i - 1] == 0:
		d[i - 1] = 1
	elif d[i] == 0:
		d[i] = 1
	elif d[i + 1] == 0:
		d[i + 1] = 1
print(len(d))


n = int(input())
b = list()
for i in range(150002):
	b.append(0)
a = list(map(int, input().split()))
a.sort()
for i in range(n):
	if a[i] == 1:
		if b[a[i]] == 0:
			b[a[i]] = 1
		elif b[a[i] + 1] == 0:
			b[a[i] + 1] = 1
	elif b[a[i] - 1] == 0:
		b[a[i] - 1] = 1
	elif b[a[i]] == 0:
		b[a[i]] = 1
	elif b[a[i] + 1] == 0:
		b[a[i] + 1] = 1
cn = 0
for i in range(150002):
	if b[i] == 1:
		cn += 1
print(cn)


n = int(input())
b = list(map(int, input().split()))
b.sort(reverse=True)
k = [b[0] + 1]
for i in b[1:]:
	if k[-1] > i + 1:
		k.append(i + 1)
	elif k[-1] > i:
		k.append(i)
	elif k[-1] > i - 1 and i != 1:
		k.append(i - 1)
print(len(k))


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 sys
input = sys.stdin.readline
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))


from collections import defaultdict as DD
from bisect import bisect_left as BL
from bisect import bisect_right as BR
from itertools import combinations as IC
from itertools import permutations as IP
from random import randint as RI
import sys
import math
MOD = pow(10, 9) + 7
from math import gcd

def IN(f=0):
	if f == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = IN(1)
a = IN()
a.sort()
c = 0
h = [0 for i in range(150000 + 2)]
for i in range(len(a)):
	flag = 1
	if a[i] - 1 > 0 and h[a[i] - 1] == 0:
		h[a[i] - 1] = 1
		flag = 0
	if flag == 1 and h[a[i]] == 0:
		h[a[i]] = 1
		flag = 0
	if flag == 1 and h[a[i] + 1] == 0:
		h[a[i] + 1] = 1
print(sum(h))


def num_limit(n):
	if n >= 1 and n <= 150000:
		return True
	else:
		return False
limit_in = int(input())
member_in = input()
parse = member_in.split(' ')
numlist = []
for i in range(0, len(parse)):
	numlist.append(int(parse[i]))
numlist.sort()
current = numlist[0]
weight = len(numlist)
if current > 1:
	current -= 1
count = 0
for i in range(1, limit_in):
	if numlist[i] > current:
		if numlist[i] - current > 1:
			count += 1
			current = numlist[i] - 1
		else:
			count += 1
			current = numlist[i]
	elif numlist[i] == current:
		current = numlist[i] + 1
		count += 1
if weight == 0:
	count = 0
print(count + 1)


n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict as dd
d = dd(int)
a.sort()
for i in range(n):
	lo = max(1, a[i] - 1)
	hi = min(150001, a[i] + 1)
	if d[lo] == 0:
		d[lo] = 1
	elif d[a[i]] == 0:
		d[a[i]] = 1
	elif d[hi] == 0:
		d[hi] = 1
print(len(d.keys()))


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
c = 0
d = 0
e = 0
if a[0] - 1 != 0:
	c = a[0] - 1
else:
	c = a[0]
k = 1
for i in range(1, n):
	if a[i] - 1 != 0 and a[i] - 1 != c and (a[i] - 1 != d) and (a[i] - 1 != e):
		(c, d, e) = (a[i] - 1, c, d)
		k += 1
	elif a[i] != c and a[i] != d and (a[i] != e):
		(c, d, e) = (a[i], c, d)
		k += 1
	elif a[i] + 1 != c and a[i] + 1 != d and (a[i] + 1 != e):
		(c, d, e) = (a[i] + 1, c, d)
		k += 1
print(k)


def main():
	d = int(input())
	data = [int(v) for v in input().split()]
	data.sort()
	added = set()
	for v in data:
		if v - 1 not in added and v - 1 > 0:
			added.add(v - 1)
		elif v not in added:
			added.add(v)
		elif v + 1 not in added:
			added.add(v + 1)
	print(len(added))
main()


n = int(input())
a = sorted(list(map(int, input().split())))
s = set()
for i in a:
	for j in range(-1, 2):
		x = max(1, i + j)
		if x not in s:
			s.add(x)
			break
print(len(s))


from sys import stdin
import math
testcases = False
from collections import defaultdict
if testcases:
	t = int(stdin.readline())
	while t:
		n = int(stdin.readline())
		a = list(map(int, stdin.readline().split()))
		t -= 1
else:
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	ans = 0
	d = defaultdict(bool)
	for i in range(n):
		if a[i] - 1 > 0 and d[a[i] - 1] == False:
			d[a[i] - 1] = True
			ans += 1
		elif d[a[i]] == False:
			ans += 1
			d[a[i]] = True
		elif a[i] + 1 < 150002 and d[a[i] + 1] == False:
			d[a[i] + 1] = True
			ans += 1
	print(ans)


import sys
input = sys.stdin.buffer.readline
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(150005)]
c = [0 for i in range(150005)]
for i in range(n):
	b[a[i]] += 1
for i in range(150001):
	if b[i] > 0:
		if c[i - 1] == 0 and i > 1:
			b[i] -= 1
			c[i - 1] = 1
		if b[i] > 0:
			if c[i] == 0:
				b[i] -= 1
				c[i] = 1
			if b[i] > 0:
				if c[i + 1] == 0:
					b[i] -= 1
					c[i + 1] = 1
print(c.count(1))


n = int(input())
boxers = list(map(int, input().split()))
boxers.sort(reverse=True)
weight = set()
cnt = 0
for i in range(n):
	w = boxers[i]
	if w + 1 not in weight:
		weight.add(w + 1)
		cnt += 1
	elif w not in weight:
		weight.add(w)
		cnt += 1
	elif w - 1 not in weight:
		if w - 1 == 0:
			continue
		weight.add(w - 1)
		cnt += 1
print(cnt)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
n = INT()
a = LIST()
occ = defaultdict(int)
vis = [False] * (n + 1)
for el in a:
	occ[el] += 1
a.sort()
set1 = set(a)
mx = a[-1]
ans = 0
canfill = 0
needL = 0
for i in range(1, mx + 2):
	if i in set1:
		if occ[i] >= 3:
			canfill = 2
		elif occ[i] == 2:
			canfill = max(canfill, 1)
		ans += 1
		if needL == 1 and canfill > 0:
			ans += 1
			canfill -= 1
			needL = 0
	else:
		needL = 1
		if canfill > 0:
			ans += 1
			needL = 0
		canfill = 0
print(ans)


from collections import *
from inspect import currentframe
from math import *
from sys import stdin, stdout, stderr

def main():
	oo = 4557430888798830399
	eps = 1e-09

	def TR(n):
		if True:
			x = currentframe().f_back.f_locals[n]
			stderr.write('{} = {}\n'.format(n, x))
	ddict = defaultdict
	rl = stdin.readline
	rc = stdin.read
	wr = stdout.write
	n = int(rl())
	xs = sorted(map(int, rl().split()))
	c = 0
	res = []
	for x in xs:
		if x - 1 > c:
			res.append(x - 1)
			c = x - 1
		elif x > c:
			res.append(x)
			c = x
		elif x + 1 > c:
			res.append(x + 1)
			c = x + 1
	wr(f'{len(res)}\n')
main()


num_box = int(input())
list_weights = list(map(int, input().split(' ')))
list_weights.sort()
visited_set = set()
for (idx, w) in enumerate(list_weights):
	if w - 1 not in visited_set and w - 1 != 0:
		visited_set.add(w - 1)
		list_weights[idx] = w - 1
	elif w not in visited_set:
		visited_set.add(w)
	elif w + 1 not in visited_set:
		visited_set.add(w + 1)
		list_weights[idx] = w + 1
print(len(visited_set))


from collections import deque
import sys, collections
MAX = 150001

def inp():
	return sys.stdin.readline().strip()
n = int(inp())
a = list(map(int, inp().split()))
status = [0] * (MAX + 1)
for i in a:
	status[i] += 1
i = 1
ct = 0
prev = -1
while i <= MAX:
	if status[i] == 0:
		prev = i
		i += 1
	else:
		j = i
		mx = 0
		while j <= MAX and status[j] > 0:
			ct += 1
			mx += max(0, status[j] - 1)
			j += 1
		if mx == 0:
			i = j
			prev = j
			continue
		if mx >= 2:
			if prev != -1:
				prev = -1
				ct += 1
			ct += 1
			i = j + 1
			continue
		if prev != -1:
			ct += 1
			prev = j
			i = j
		else:
			prev = -1
			i = j + 1
			ct += 1
print(ct)


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
k = [0] * 150002
count = 0
for i in arr:
	if i - 1 != 0 and k[i - 1] == 0:
		k[i - 1] += 1
		count += 1
		continue
	elif k[i] == 0:
		k[i] += 1
		count += 1
		continue
	elif k[i + 1] == 0:
		k[i + 1] += 1
		count += 1
		continue
print(count)


from sys import stdin, stdout
from math import gcd, sqrt, inf
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
M = inf
n = I()
v = [0] * (15 * 10000 + 7)
v[0] = 1
for i in sorted(R()):
	if not v[i - 1]:
		v[i - 1] = 1
	elif not v[i]:
		v[i] = 1
	elif not v[i + 1]:
		v[i + 1] = 1
print(v.count(1) - 1)


n = int(input())
a = [int(i) for i in input().split()]
b = []
ans = 0
a.sort()
if a[0] == 1:
	b.append(1)
	ans += 1
else:
	b.append(a[0] - 1)
	ans += 1
for i in range(1, n):
	if b[-1] < a[i] - 1:
		ans += 1
		b.append(a[i] - 1)
	elif b[-1] < a[i]:
		ans += 1
		b.append(a[i])
	elif b[-1] < a[i] + 1:
		b.append(a[i] + 1)
		ans += 1
print(ans)


from collections import defaultdict as dc
vis = dc(lambda : 0)
x = int(input())
s = sorted(list(map(int, input().split())))
vis[0] = 1
res = 0
for n in s:
	if not vis[n - 1]:
		vis[n - 1] = 1
		res += 1
	elif not vis[n]:
		vis[n] = 1
		res += 1
	elif not vis[n + 1]:
		vis[n + 1] = 1
		res += 1
print(res)


from sys import stdin
input = stdin.readline
n = int(input())
a = sorted([int(i) for i in input().split()])
res = 1
if a[0] > 1:
	acc = a[0] - 1
else:
	acc = 1
for i in range(1, n):
	if a[i] > acc + 1:
		res += 1
		acc = a[i] - 1
	elif a[i] >= acc:
		res += 1
		acc += 1
print(res)


n = int(input())
l = list(map(int, input().split()))
d = set()
l.sort(reverse=True)
for i in range(n):
	if l[i] + 1 not in d:
		d.add(l[i] + 1)
	elif l[i] not in d:
		d.add(l[i])
	elif l[i] - 1 not in d:
		d.add(l[i] - 1)
t = 0
if 0 in d:
	t = 1
print(len(d) - t)


import sys
input = lambda : sys.stdin.readline().strip()
from math import *
n = int(input())
ls = list(map(int, input().split()))
ls.sort()
cur = 0
cnt = 0
for i in ls:
	if max(cur + 1, i - 1) != cur and i - 1 <= max(cur + 1, i - 1) <= i + 1:
		cnt += 1
		cur = max(cur + 1, i - 1)
print(cnt)


N = int(input())
nums = list(map(int, input().split()))
nums = sorted(nums)
arr = [0 for x in range(150005)]
for i in range(N):
	if not arr[nums[i] - 1] and nums[i] != 1:
		arr[nums[i] - 1] = 1
	elif not arr[nums[i]]:
		arr[nums[i]] = 1
	elif not arr[nums[i] + 1]:
		arr[nums[i] + 1] = 1
print(sum(arr[1:]))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = [0] * 150002
for ai in a:
	if ai - 1 > 0 and flag[ai - 1] == 0:
		flag[ai - 1] = 1
	elif flag[ai] == 0:
		flag[ai] = 1
	else:
		flag[ai + 1] = 1
print(flag.count(1))


n = int(input())
a = sorted(list(map(int, input().split())))
cur = 0
ans = 0
for i in a:
	if cur < i - 1:
		cur = i - 1
		ans += 1
	elif cur == i - 1:
		cur = i
		ans += 1
	elif cur == i:
		cur = i + 1
		ans += 1
print(ans)


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)


def boxer_team(team: list) -> int:
	team.sort(reverse=True)
	new_team = set()
	for boxer in team:
		if boxer < 150001 and boxer + 1 not in new_team:
			new_team.add(boxer + 1)
		elif boxer not in new_team:
			new_team.add(boxer)
		elif boxer > 1 and boxer - 1 not in new_team:
			new_team.add(boxer - 1)
	return len(new_team)
n = int(input())
l = list(map(lambda x: int(x), input().split()))
print(boxer_team(l))


numweights = int(input())
weights = list(map(lambda num: int(num), input().split()))
weights.sort()
team = set()
for weight in weights:
	if weight - 1 != 0 and weight - 1 not in team:
		team.add(weight - 1)
	elif weight not in team:
		team.add(weight)
	elif weight + 1 not in team:
		team.add(weight + 1)
print(len(team))


import random
n = int(input())
s = list(map(int, input().split()))
temp = []
j = 0
s.sort()
for i in range(0, n, 1):
	if len(temp) < 10:
		if not s[i] - 1 in temp and s[i] - 1 > 0:
			temp.append(s[i] - 1)
			j += 1
		elif not s[i] in temp:
			temp.append(s[i])
			j += 1
		elif not s[i] + 1 in temp:
			temp.append(s[i] + 1)
			j += 1
	elif (s[i] - 1 != temp[j - 3] and s[i] - 1 != temp[j - 2] and (s[i] - 1 != temp[j - 1])) and s[i] - 1 > 0:
		temp.append(s[i] - 1)
		j += 1
	elif s[i] - 1 != temp[j - 3] and s[i] != temp[j - 2] and (s[i] != temp[j - 1]):
		temp.append(s[i])
		j += 1
	elif s[i] - 1 != temp[j - 3] and s[i] + 1 != temp[j - 2] and (s[i] + 1 != temp[j - 1]):
		temp.append(s[i] + 1)
		j += 1
print(len(temp))


import sys
input = sys.stdin.readline
N = 150002
(a, b) = ([0] * N, [0] * N)
_ = input()
for x in input().split():
	a[int(x)] += 1
for i in range(1, N - 1):
	while a[i]:
		a[i] -= 1
		if i > 1 and (not b[i - 1]):
			b[i - 1] = 1
		elif not b[i]:
			b[i] = 1
		else:
			b[i + 1] = 1
print(sum(b))


n = int(input())
a = list(map(int, input().split()))
p = [0] * (max(a) + 2)
q = [0] * (max(a) + 2)
for i in a:
	p[i] += 1
ans = 0
for i in range(1, max(a) + 1):
	if i == 1:
		if q[i] == 0 and p[i] > 0:
			q[i] = 1
			p[i] -= 1
		if q[i + 1] == 0 and p[i] > 0:
			q[i + 1] = 1
	else:
		if q[i - 1] == 0 and p[i] > 0:
			q[i - 1] = 1
			p[i] -= 1
		if q[i] == 0 and p[i] > 0:
			q[i] = 1
			p[i] -= 1
		if q[i + 1] == 0 and p[i] > 0:
			q[i + 1] = 1
print(sum(q))


from collections import *
n = int(input())
l = [*map(int, input().split())]
dic = Counter(l)
dic = OrderedDict(sorted(dic.items(), key=lambda x: x[0], reverse=True))
s = set()
for i in dic:
	if dic[i] == 1:
		if i + 1 not in s:
			s.add(i + 1)
		elif i not in s:
			s.add(i)
		elif i - 1 > 0 and i - 1 not in s:
			s.add(i - 1)
	elif dic[i] == 2:
		if i in s:
			if i - 1 > 0 and i - 1 not in s:
				s.add(i - 1)
			s.add(i + 1)
		else:
			s.add(i)
			if i + 1 not in s:
				s.add(i + 1)
			elif i - 1 > 0:
				s.add(i - 1)
	else:
		s.add(i)
		s.add(i + 1)
		if i - 1 > 0:
			s.add(i - 1)
print(len(s))


import sys
from collections import defaultdict as dd
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
check = [0 for i in range(150002)]
n = ri(1)
a = ri()
a.sort()
for i in a:
	done = 0
	if i - 1 > 0:
		if check[i - 1] == 0:
			check[i - 1] = 1
			done = 1
	if done == 0:
		if check[i] == 0:
			check[i] = 1
			done = 1
	if done == 0:
		if check[i + 1] == 0:
			check[i + 1] = 1
print(sum(check))


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


n = int(input())
i = [int(x) for x in input().split()]
i = sorted(i)
unique = 0
maxNum = 0
for w in i:
	if maxNum < w - 1:
		maxNum = w - 1
		unique += 1
	elif maxNum < w:
		maxNum = w
		unique += 1
	elif maxNum < w + 1:
		maxNum = w + 1
		unique += 1
print(unique)


n = int(input())
L = sorted(list(map(int, input().split())))
S = set()
for i in L:
	for j in range(-1, 2):
		tmp = max(1, i + j)
		if tmp not in S:
			S.add(tmp)
			break
print(len(S))


import sys
from collections import defaultdict
n = int(sys.stdin.readline())
lst = list(map(int, sys.stdin.readline().split()))
lst.sort()
count = 0
Dict = defaultdict(int)
for i in lst:
	if Dict[i - 1] != 1 and i != 1:
		Dict[i - 1] = 1
		count += 1
	elif Dict[i] != 1:
		Dict[i] = 1
		count += 1
	elif Dict[i + 1] != 1:
		Dict[i + 1] = 1
		count += 1
if Dict[150002] == 1:
	count -= 1
print(count)


num = int(input())
num1 = list(map(int, input().split(' ')))
num1.sort()
sizes = set()
for i in num1:
	if i - 1 not in sizes and i != 1:
		sizes.add(i - 1)
	elif i not in sizes:
		sizes.add(i)
	elif i + 1 not in sizes:
		sizes.add(i + 1)
	else:
		continue
print(len(sizes))


n = int(input())
inputlist = list(map(int, input().split()))
inputlist.sort()
boxerset = set()
maxweightonteam = 0
countonteam = 0
for ai in inputlist:
	if ai < maxweightonteam:
		continue
	assert ai + 1 >= maxweightonteam + 1
	maxweightonteam = max(maxweightonteam + 1, ai - 1)
	countonteam += 1
print(countonteam)


n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
s = set()
for i in arr:
	if i + 1 not in s:
		s.add(i + 1)
	elif i not in s:
		s.add(i)
	elif i - 1 not in s and i - 1 > 0:
		s.add(i - 1)
print(len(s))


n = int(input())
w = str(input())
w = w.split()
boxers = [int(i) for i in w]
flag = 0
dup = set()
uniq = []
boxers.sort()
if len(w) == n:
	for x in boxers:
		if x not in dup and x != 0:
			if x - 1 not in dup and x - 1 != 0:
				uniq.append(x - 1)
				dup.add(x - 1)
			else:
				uniq.append(x)
				dup.add(x)
		elif x in dup and x != 0:
			new = x + 1
			if new in dup:
				new = x - 1
				if new in dup:
					new = 0
				elif new not in dup and new != 0:
					uniq.append(new)
					dup.add(new)
			else:
				uniq.append(new)
				dup.add(new)
	print(len(uniq))


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))

def inps():
	return sys.stdin.readline()

def inpsl(x):
	tmp = sys.stdin.readline()
	return list(tmp[:x])

def err(x):
	print(x)
	exit()
n = inp()
a = inpl()
a.sort()
c = Counter(a)
se = set()
for x in a:
	if x - 1 != 0 and c[x - 1] == 0:
		c[x - 1] += 1
		c[x] -= 1
	elif c[x] > 1:
		c[x + 1] += 1
		c[x] -= 1
res = 0
for (key, va) in c.items():
	if va > 0:
		res += 1
print(res)


n = int(input())
a = list(map(int, input().split()))
b = [0] * 150005
for _ in range(len(a)):
	b[a[_]] += 1
a.sort()
for _ in range(len(a)):
	if a[_] - 1 != 0 and b[a[_] - 1] == 0:
		b[a[_]] -= 1
		a[_] = a[_] - 1
		b[a[_]] += 1
	elif b[a[_]] > 1:
		b[a[_]] -= 1
		a[_] += 1
		b[a[_]] += 1
c = [0] * (max(a) + 5)
f = 0
for _ in range(len(a)):
	if c[a[_]] == 0:
		f += 1
	c[a[_]] += 1
print(f)


def binarySearch(arr, left, right, key):
	while left <= right:
		mid = left + (right - left) // 2
		if arr[mid] == key:
			return True
		elif arr[mid] < key:
			left = mid + 1
		else:
			right = mid - 1
	return False
boxers = int(input())
weights = input().split(' ')
weights = [int(i) for i in weights]
weights.sort()
sortedBoxers = []
count = 0
for i in range(0, boxers):
	boxerWeight = int(weights[i])
	if binarySearch(sortedBoxers, 0, len(sortedBoxers) - 1, boxerWeight - 1) == False and boxerWeight - 1 >= 1:
		sortedBoxers.append(boxerWeight - 1)
	elif binarySearch(sortedBoxers, 0, len(sortedBoxers) - 1, boxerWeight) == False:
		sortedBoxers.append(boxerWeight)
	elif binarySearch(sortedBoxers, 0, len(sortedBoxers) - 1, boxerWeight + 1) == False and boxerWeight + 1 <= 150001:
		sortedBoxers.append(boxerWeight + 1)
print(len(sortedBoxers))


n = int(input())
a = sorted(list(map(int, input().split()))) + [-1]
ans = 0
dop = 0
res = 0
block = []
for i in range(n + 1):
	if len(block) == 0 or block[-1] + 1 == a[i]:
		block += [a[i]]
	elif len(block) > 0 and block[-1] == a[i]:
		dop += 1
	else:
		if res + 1 == block[0]:
			ans += len(block)
			if dop >= 1:
				ans += 1
				res = block[-1] + 1
		else:
			ans += len(block)
			if dop >= 1:
				ans += 1
			if dop >= 2:
				ans += 1
				res = block[-1] + 1
		block = [a[i]]
		dop = 0
print(ans)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
arr = lmp()
arr.sort()
mn = 0
inc = 0
for i in range(n):
	if arr[i] > mn + 1:
		arr[i] -= 1
		inc += 1
		mn = arr[i]
	elif arr[i] == mn + 1:
		inc += 1
		mn = arr[i]
	elif arr[i] == mn:
		arr[i] += 1
		inc += 1
		mn = arr[i]
print(inc)


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)


size = input()
number = input().split()
listnumber = []
counter = 0
availlist = [0 for i in range(150002)]
availlist[0] = 1
for i in range(len(number)):
	listnumber.append(int(number[i]))
listnumber.sort()
for i in range(len(listnumber)):
	if availlist[listnumber[i] - 1] == 0:
		counter += 1
		availlist[listnumber[i] - 1] = 1
	elif availlist[listnumber[i]] == 0:
		counter += 1
		availlist[listnumber[i]] = 1
	elif availlist[listnumber[i] + 1] == 0:
		counter += 1
		availlist[listnumber[i] + 1] = 1
print(counter)


N = int(input())
nums = input().split()
for i in range(N):
	nums[i] = int(nums[i])
seen = set()
nums.sort()
for i in range(N):
	old = len(seen)
	num = nums[i]
	if num - 1 > 0:
		seen.add(num - 1)
	if len(seen) == old:
		seen.add(num)
	if len(seen) == old:
		seen.add(num + 1)
print(len(seen))


def main():
	numBoxers = int(input())
	boxersWeight = input()
	weights = []
	splitWeight = boxersWeight.split(' ')
	for i in range(numBoxers):
		weights.append(int(splitWeight[i]))
	weights.sort()
	ans = 0
	mx = 1
	for i in range(numBoxers):
		if weights[i] == mx:
			mx += 1
			ans += 1
		elif weights[i] > mx:
			ans += 1
			mx = weights[i]
		elif mx - weights[i] == 1:
			ans += 1
			mx += 1
	print(ans)
main()


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)


n = int(input())
a = list(map(int, input().strip().split()))
a.sort()
visited = [0] * 1500010
visited[0] = 1
ans = 0
for i in range(0, n):
	if visited[a[i] - 1] == 0:
		ans += 1
		visited[a[i] - 1] += 1
	elif visited[a[i]] == 0:
		visited[a[i]] += 1
		ans += 1
	elif visited[a[i] + 1] == 0:
		visited[a[i] + 1] += 1
		ans += 1
print(ans)


from collections import Counter
n = int(input())
ar = sorted([int(x) for x in input().split()])
x = set()
for i in ar:
	if i != 1:
		if i - 1 not in x:
			x.add(i - 1)
		elif i not in x:
			x.add(i)
		elif i + 1 not in x:
			x.add(i + 1)
	elif i not in x:
		x.add(i)
	elif i + 1 not in x:
		x.add(i + 1)
print(n if len(x) >= n else len(x))


(n, a) = (int(input()), sorted(map(int, input().split())))
s = set()
for i in range(n):
	v = a[i]
	if v != 1 and v - 1 not in s:
		s.add(v - 1)
	elif v not in s:
		s.add(v)
	else:
		s.add(v + 1)
print(len(s))


import sys
maxn = 1500005
visited = [0] * maxn
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
arr.sort(reverse=True)
count = 0
for i in range(n):
	if not visited[arr[i] + 1]:
		count += 1
		arr[i] += 1
		visited[arr[i]] += 1
	elif not visited[arr[i]]:
		count += 1
		visited[arr[i]] += 1
	elif not visited[arr[i] - 1] and arr[i] > 1:
		count += 1
		arr[i] -= 1
		visited[arr[i]] += 1
print(count)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
n = iinput()
a = get_list()
a.sort()
d = {}
for i in range(n):
	if a[i] > 1 and d.get(a[i] - 1, 0) == 0:
		d[a[i] - 1] = 1
	elif d.get(a[i], 0) == 0:
		d[a[i]] = 1
	else:
		d[a[i] + 1] = 1
ans = len(list(d.keys()))
print(ans)


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a[0] += 1
ans = 0
for i in range(1, n):
	if a[i] == a[i - 1] and a[i] != 1:
		a[i] -= 1
		ans += 1
	elif a[i] == a[i - 1] - 1:
		ans += 1
	elif a[i] < a[i - 1] - 1:
		ans += 1
		a[i] += 1
	elif a[i] > a[i - 1]:
		a[i] -= 1
print(ans + 1)


n = int(input().strip())
nums = [int(i) for i in input().strip().split()]
nums.sort()
have = set()
for i in range(n):
	if nums[i] - 1 not in have and nums[i] != 1:
		have.add(nums[i] - 1)
	elif nums[i] not in have:
		have.add(nums[i])
	else:
		have.add(nums[i] + 1)
if 0 in have:
	print(len(have) - 1)
else:
	print(len(have))


n = int(input())
arr = list(map(int, input().split(' ')))
arr.sort()
ans = set([arr[n - 1] + 1])
for i in range(n - 2, -1, -1):
	plus = arr[i] + 1
	minus = arr[i] - 1
	if plus not in ans:
		ans.add(plus)
	elif arr[i] not in ans:
		ans.add(arr[i])
	elif minus not in ans and minus != 0:
		ans.add(minus)
print(len(ans))


import sys

def inpt():
	return sys.stdin.readline().strip()
n = int(inpt())
mas = sorted([int(i) for i in inpt().split()])
x = []
for a in mas:
	if len(x) == 0:
		if a != 1:
			x.append(a - 1)
		else:
			x.append(a)
	elif x[len(x) - 1] != a - 1 and len(x) >= 3 and (x[len(x) - 2] != a - 1) and (a - 1 != 0) and (x[len(x) - 3] != a - 1):
		x.append(a - 1)
	elif x[len(x) - 1] != a - 1 and len(x) == 2 and (x[len(x) - 2] != a - 1) and (a - 1 != 0):
		x.append(a - 1)
	elif x[len(x) - 1] != a - 1 and len(x) < 2 and (a - 1 != 0):
		x.append(a - 1)
	elif x[len(x) - 1] != a and len(x) >= 3 and (x[len(x) - 2] != a) and (x[len(x) - 3] != a):
		x.append(a)
	elif x[len(x) - 1] != a and len(x) == 2 and (x[len(x) - 2] != a):
		x.append(a)
	elif x[len(x) - 1] != a and len(x) < 2:
		x.append(a)
	elif x[len(x) - 1] != a + 1 and len(x) >= 3 and (x[len(x) - 2] != a + 1) and (x[len(x) - 3] != a + 1):
		x.append(a + 1)
	elif x[len(x) - 1] != a + 1 and len(x) >= 2 and (x[len(x) - 2] != a + 1):
		x.append(a + 1)
	elif x[len(x) - 1] != a + 1 and len(x) < 2:
		x.append(a + 1)
print(len(x))


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


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a1 = Counter(a)
s = []
a1k = sorted(list(a1.keys()))
for key in a1k:
	if a1[key] == 1:
		if s and s[-1] < key - 1 and (key - 1 > 0):
			s.append(key - 1)
		elif s and s[-1] == key - 1:
			s.append(key)
		elif s and s[-1] == key:
			s.append(key + 1)
		if not s:
			if key - 1 > 0:
				s.append(key - 1)
			else:
				s.append(key)
	elif a1[key] == 2:
		if s and s[-1] < key - 1 and (key > 0):
			s.append(key - 1)
			s.append(key)
		elif s and s[-1] == key - 1:
			s.append(key)
			s.append(key + 1)
		elif s and s[-1] == key:
			s.append(key + 1)
		if not s:
			if key - 1 > 0:
				s.append(key - 1)
				s.append(key)
			else:
				s.append(key)
				s.append(key + 1)
	else:
		if s and s[-1] < key - 1 and (key > 0):
			s.append(key - 1)
			s.append(key)
			s.append(key + 1)
		elif s and s[-1] == key - 1:
			s.append(key)
			s.append(key + 1)
		elif s and s[-1] == key:
			s.append(key + 1)
		if not s:
			if key - 1 > 0:
				s.append(key - 1)
				s.append(key)
				s.append(key + 1)
			else:
				s.append(key)
				s.append(key + 1)
print(len(s))


n = int(input())
arr = list(map(int, input().split(' ')))
arr.sort(reverse=True)
cnt = 0
arr[0] += 1
cnt = 1
for i in range(1, n):
	if arr[i] > arr[i - 1]:
		arr[i] = arr[i - 1]
	elif arr[i] == arr[i - 1]:
		if arr[i] - 1 > 0:
			arr[i] -= 1
			cnt += 1
	elif arr[i] + 1 == arr[i - 1]:
		cnt += 1
	elif arr[i] + 1 != arr[i - 1]:
		arr[i] += 1
		cnt += 1
print(cnt)


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
	elif hsh[i] == 0:
		hsh[i] = 1
	elif hsh[i + 1] == 0:
		hsh[i + 1] = 1
print(hsh.count(1) - 1)


from collections import defaultdict
import heapq
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
heapq.heapify(a)
ok = defaultdict(lambda : 0)
ans = 0
while a:
	i = heapq.heappop(a)
	if not ok[i - 1] and i - 1 > 0:
		ok[i - 1] = 1
		ans += 1
	elif not ok[i]:
		ok[i] = 1
		ans += 1
	elif not ok[i + 1]:
		ok[i + 1] = 1
		ans += 1
print(ans)


n = int(input())
(*a,) = map(int, input().split())
a = sorted(a)
h = 0
c = 0
for x in a:
	if x - 1 != 0 and x - 1 > h:
		h = x - 1
		c += 1
	elif x > h:
		h = x
		c += 1
	elif x + 1 > h:
		h = x + 1
		c += 1
print(c)


from io import BytesIO, IOBase
from math import sqrt
import sys, os
from os import path
inpl = lambda : list(map(int, input().split()))
inpm = lambda : map(int, input().split())
inpi = lambda : int(input())
inp = lambda : input()
(rev, ra, l) = (reversed, range, len)
P = print
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def B(n):
	return bin(n).replace('0b', '')

def factors(n):
	arr = []
	for i in ra(2, int(sqrt(n)) + 1):
		if n % i == 0:
			arr.append(i)
			if i * i != n:
				arr.append(int(n / i))
	return arr

def prime_factors(n):
	omap = {2: 0}
	while n != 1 and n % 2 == 0:
		omap[2] += 1
		n /= 2
	for i in ra(3, int(math.sqrt(n)) + 1, 2):
		while n != 1 and n % i == 0:
			if i not in omap:
				omap[i] = 1
			else:
				omap[i] += 1
			n /= i
	if n != 1:
		omap[int(n)] = 1
	return omap

def dfs(arr, n):
	pairs = [[i + 1] for i in ra(n)]
	vis = [0] * (n + 1)
	for i in ra(l(arr)):
		pairs[arr[i][0] - 1].append(arr[i][1])
	pairs[arr[i][1] - 1].append(arr[i][0])
	comp = []
	for i in ra(n):
		stack = [pairs[i]]
		temp = []
		if vis[stack[-1][0]] == 0:
			while len(stack) > 0:
				if vis[stack[-1][0]] == 0:
					temp.append(stack[-1][0])
					vis[stack[-1][0]] = 1
					s = stack.pop()
					for j in s[1:]:
						if vis[j] == 0:
							stack.append(pairs[j - 1])
				else:
					stack.pop()
			comp.append(temp)
	return comp
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys, operator, math, operator
from collections import Counter
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import random
n = inpi()
li = inpl()
omap = {}
li.sort()
ans = 0
for i in ra(n):
	if li[i] - 1 not in omap and li[i] - 1 > 0:
		ans += 1
		omap[li[i] - 1] = 1
	elif li[i] not in omap:
		ans += 1
		omap[li[i]] = 1
	elif li[i] + 1 not in omap:
		ans += 1
		omap[li[i] + 1] = 1
P(ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
met = set()
for t in a:
	if t - 1 > 0 and t - 1 not in met:
		met.add(t - 1)
	elif t not in met:
		met.add(t)
	elif t + 1 not in met:
		met.add(t + 1)
print(len(met))


n = int(input())
a = list(map(int, input().split()))
a.sort()
c = set()
if a[0] != 1:
	c.add(a[0] - 1)
else:
	c.add(a[0])
for i in range(1, n):
	if a[i] != 1 and a[i] - 1 not in c:
		c.add(a[i] - 1)
	elif a[i] not in c:
		c.add(a[i])
	elif a[i] + 1 not in c:
		c.add(a[i] + 1)
print(len(c))
exit(0)


n = int(input())
from collections import Counter
a = list(map(int, input().split()))
count = dict(Counter(a))
a.sort()
segments = []
curr = [a[0]]
for i in range(1, n):
	if a[i] == curr[-1] or a[i] - curr[-1] == 1:
		curr.append(a[i])
	else:
		segments.append(curr)
		curr = [a[i]]
segments.append(curr)
for seg in segments:
	if len(seg) - len(set(seg)) == 0:
		continue
	if len(seg) - len(set(seg)) == 1:
		if seg[0] == 1 or seg[0] - 1 in count:
			count[seg[-1] + 1] = 1
		else:
			count[seg[0] - 1] = 1
	else:
		if seg[0] != 1:
			count[seg[0] - 1] = 1
		count[seg[-1] + 1] = 1
print(len(count))


n = int(input())
ar = list(map(int, input().split()))
ans = 0
h = [0] * 150011
ar.sort()
for i in ar:
	if h[i - 1] == 0 and i != 1:
		ans += 1
		h[i - 1] = 1
	elif h[i] == 0:
		ans += 1
		h[i] = 1
	elif h[i + 1] == 0:
		ans += 1
		h[i + 1] = 1
print(ans)


def max_number_boxers(elements):
	elements = sorted(elements, reverse=True)
	stack = []
	stack.append(elements[0] + 1)
	counter = 1
	for it in range(1, len(elements)):
		if elements[it] + 1 < stack[-1]:
			stack.append(elements[it] + 1)
			counter += 1
		elif elements[it] + 1 == stack[-1]:
			stack.append(elements[it])
			counter += 1
		elif elements[it] == stack[-1]:
			if elements[it] > 1:
				stack.append(elements[it] - 1)
				counter += 1
			else:
				pass
		else:
			pass
	return counter
number_of_elements = input()
elements = input().split()
elements = list(map(int, elements))
print(max_number_boxers(elements))


n = int(input())
a = [int(x) for x in input().split()]
freq = {}
for a0 in a:
	if a0 not in freq:
		freq[a0] = 0
	freq[a0] += 1
ans = 0
for i in range(1, max(a) + 2):
	if i - 1 in freq and freq[i - 1] > 0:
		ans += 1
		freq[i - 1] -= 1
	elif i in freq and freq[i] > 0:
		ans += 1
		freq[i] -= 1
	elif i + 1 in freq and freq[i + 1] > 0:
		ans += 1
		freq[i + 1] -= 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort()
s = set()
cnt = 0
l = l[::-1]
for i in l:
	if i + 1 <= 150001:
		if i + 1 not in s:
			cnt = cnt + 1
			s.add(i + 1)
			continue
	if i not in s:
		cnt = cnt + 1
		s.add(i)
		continue
	if i - 1 > 0:
		if i - 1 not in s:
			cnt = cnt + 1
			s.add(i - 1)
			continue
print(cnt)


n = int(input())
a = list(map(int, input().split()))
counts = [0] * 150005
a.sort()
num_ones = 0
for i in range(len(a)):
	if a[i] != 1:
		break
	num_ones += 1
if num_ones >= 1:
	counts[1] = 1
if num_ones >= 2:
	counts[2] = 1
for i in range(num_ones, len(a)):
	if counts[a[i] - 1] == 0:
		counts[a[i] - 1] += 1
	elif counts[a[i]] == 0:
		counts[a[i]] += 1
	elif counts[a[i] + 1] == 0:
		counts[a[i] + 1] += 1
num_nonzero = 0
for c in counts:
	if c > 0:
		num_nonzero += 1
print(num_nonzero)


import os
from io import BytesIO, IOBase
import sys

def main():
	n = int(input())
	a = sorted(map(int, input().split()))
	b = [1] * (max(a) + 2)
	for i in range(n):
		if a[i] - 1 and b[a[i] - 1]:
			b[a[i] - 1] = 0
		elif b[a[i]]:
			b[a[i]] = 0
		elif b[a[i] + 1]:
			b[a[i] + 1] = 0
	print(b.count(0))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
set = set()
a.sort()
for i in a:
	if i != 1:
		if i - 1 not in set:
			set.add(i - 1)
		elif i not in set:
			set.add(i)
		else:
			set.add(i + 1)
	elif i == 1:
		if 1 in set:
			set.add(i + 1)
		else:
			set.add(i)
print(len(set))


from __future__ import division, print_function
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
from fractions import Fraction

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)
n = ii()
l = sorted(li())
a = [0] * 150002
x = 0
if l[0] > 1:
	l[0] -= 1
	a[l[0]] = 1
	x = 1
l[-1] += 1
a[l[-1]] = 1
for i in range(x, n - 1):
	if a[max(1, l[i] - 1)] == 0:
		a[max(1, l[i] - 1)] = 1
	elif a[l[i]] == 0:
		a[l[i]] = 1
	elif a[l[i] + 1] == 0:
		a[l[i] + 1] = 1
c = 0
for i in a:
	if i != 0:
		c += 1
print(c)


input()
d = dict()
a = set()
for elem in list(map(int, input().split())):
	a.add(elem)
	if d.get(elem) is None:
		d[elem] = 1
	else:
		d[elem] += 1
a = list(a)
a.sort()
team = {0}
for elem in a:
	if d[elem] == 1:
		if elem - 1 not in team:
			team.add(elem - 1)
		elif elem not in team:
			team.add(elem)
		elif elem + 1 not in team:
			team.add(elem + 1)
	elif d[elem] >= 3:
		team.add(elem)
		team.add(elem + 1)
		team.add(elem - 1)
	if d[elem] == 2:
		if elem - 1 not in team:
			team.add(elem - 1)
			if elem not in team:
				team.add(elem)
			elif elem + 1 not in team:
				team.add(elem + 1)
		else:
			team.add(elem)
			team.add(elem + 1)
team.remove(0)
print(len(team))


n = int(input())
A = list(map(int, input().split()))
A.sort()
d = {}
for a in A:
	if a - 1 > 0 and a - 1 not in d:
		d[a - 1] = 1
	elif a not in d:
		d[a] = 1
	elif a + 1 not in d:
		d[a + 1] = 1
print(len(d.keys()))


n = int(input())
data = [int(i) for i in input().split()]
data.sort()
box = [0]
for b in data:
	if box[-1] < b - 1:
		box.append(b - 1)
	elif box[-1] < b:
		box.append(b)
	elif box[-1] == b:
		box.append(b + 1)
print(len(box) - 1)


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)


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(map(int, input().split()))
c = 0
x = 1e+20
while a:
	y = a.pop()
	for z in (y + 1, y, y - 1):
		if 0 < z < x:
			c += 1
			x = z
			break
print(c)


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)
	elif 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))


q = int(input())
x = [int(x) for x in input().split()]
x.sort()
count = {}
for i in range(x[-1] + 2):
	count[i] = 0
for i in x:
	count[i] += 1
for i in x:
	if count[i - 1] == 0 and i > 1:
		count[i - 1] = 1
		count[i] -= 1
	elif count[i] == 1:
		continue
	else:
		count[i + 1] += 1
		count[i] -= 1
answer = 0
for val in count.values():
	answer += val > 0
print(answer)


n = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse=True)
lst = l[0] + 2
ans = 0
for (o, i) in enumerate(l):
	cur = -1
	for dx in range(1, -2, -1):
		if i + dx > 0 and i + dx < lst:
			cur = i + dx
			break
	if cur == -1:
		continue
	ans += 1
	lst = cur
print(ans)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = sorted(array())
if a[0] > 1:
	a[0] -= 1
c = 1
over = set()
over.add(a[0])
last = 0
for i in range(1, n):
	if a[i] == a[last]:
		a[i] += 1
		last = i
	elif a[i] > a[last]:
		if a[i] > a[last] + 1:
			a[i] -= 1
		last = i
	over.add(a[i])
print(len(over))


n = int(input())
l = list(map(int, input().split()))
z = [0] * 150003
for i in l:
	z[i] += 1
i = 150002
while i > 0:
	t = 1
	if z[i] == 1:
		if z[i + 1] == 0:
			z[i] -= 1
			z[i + 1] += 1
		i -= 1
	elif z[i] > 1:
		if z[i + 1] == 0:
			z[i] -= 1
			z[i + 1] += 1
		if z[i - 1] == 0 and i != 1 and (z[i] > 1):
			z[i - 1] += 1
			z[i] -= 1
			t = 2
		elif z[i] > 1 and i != 1:
			z[i - 1] += z[i] - 1
			z[i] = 1
		i -= t
	else:
		i -= 1
count = 0
for i in z:
	if i > 0:
		count += 1
print(count)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 0
	q = set()
	for i in range(n):
		if a[i] == 1:
			if 1 not in q:
				q.add(1)
				ans += 1
			elif 2 not in q:
				q.add(2)
				ans += 1
		elif a[i] - 1 > 0 and a[i] - 1 not in q:
			q.add(a[i] - 1)
			ans += 1
		elif a[i] not in q:
			q.add(a[i])
			ans += 1
		elif a[i] + 1 not in q:
			q.add(a[i] + 1)
			ans += 1
		else:
			continue
	return ans
print(main())


n = int(input())
l = list(map(int, input().split()))
ans = set()
l.sort()
for i in l:
	z1 = i - 1
	z2 = i + 1
	if z1 != 0 and z1 not in ans:
		ans.add(z1)
	elif i not in ans:
		ans.add(i)
	elif z2 not in ans:
		ans.add(z2)
print(len(ans))


n = int(input())
weight = [0 for i in range(150002)]
li = list(map(int, input().split(' ')))
cnt = 0
weight[0] = 1
li.sort()
for i in li:
	if weight[i - 1] == 0:
		weight[i - 1] = 1
		cnt += 1
	elif weight[i] == 0:
		weight[i] = 1
		cnt += 1
	elif weight[i + 1] == 0:
		weight[i + 1] = 1
		cnt += 1
print(cnt)


import sys
from collections import defaultdict
arr = [0 for _ in range(150002)]
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
for i in range(n):
	arr[l[i]] += 1
i = 1
ans = 0
moved = [0 for _ in range(150002)]
r = 0
while i < 150002:
	if arr[i] != 0:
		s = 0
		j = i
		while j < 150002:
			if arr[j] != 0:
				s += arr[j]
				j += 1
			else:
				break
		if s == j - i:
			r = j - 1
			ans += j - i
			i = j
			continue
		if s == j - i + 1:
			ans += j - i + 1
			if r != i - 1:
				r = j - 1
				i = j
				continue
			else:
				r = j
				i = j + 1
				continue
		elif r != i - 1:
			ans += j - i + 2
			r = j
			i = j + 1
			continue
		else:
			ans += j - i + 1
			r = j
			i = j + 1
			continue
		i = j
	else:
		i += 1
print(ans)


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
D = [False for _ in range(1, 150003)]
n = INI()
X = sorted(INL())
ans = 0
for _ in range(n):
	if X[_] == 1:
		if D[X[_]] == False or D[X[_] + 1] == False:
			if D[X[_]] == False:
				D[X[_]] = True
			else:
				D[X[_] + 1] = True
			ans += 1
	elif D[X[_] - 1] == False or D[X[_]] == False or D[X[_] + 1] == False:
		if D[X[_] - 1] == False:
			D[X[_] - 1] = True
		elif D[X[_]] == False:
			D[X[_]] = True
		else:
			D[X[_] + 1] = True
		ans += 1
OPS(ans)


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
s = set()
d = {}
a = 0
for i in range(n):
	val = arr[i]
	if val - 1 not in s and val - 1 > 0:
		val -= 1
		s.add(val)
	elif val not in s:
		s.add(val)
	elif val + 1 not in s:
		val += 1
		s.add(val)
print(len(s))


def main():
	n = int(input())
	a = list(sorted(map(int, input().split())))
	aset = set()
	for _a in a:
		if _a - 1 > 0 and _a - 1 not in aset:
			aset.add(_a - 1)
		elif _a not in aset:
			aset.add(_a)
		elif _a + 1 not in aset:
			aset.add(_a + 1)
	print(len(aset))
main()


from sys import stdin
_input = stdin.readline
(_range, _int) = (range, int)

def solution():
	_ = _int(_input())
	arr = [_int(i) for i in _input().split()]
	n = 150000
	d = [0] * (n + 2)
	for digit in arr:
		d[digit] += 1
	ans = [0] * (n + 2)
	for i in _range(n + 1):
		if d[i] > 0:
			if d[i] == 1:
				if ans[i - 1] == 0 and i != 1:
					ans[i - 1] = 1
				elif ans[i] == 0:
					ans[i] = 1
				else:
					ans[i + 1] = 1
			elif d[i] == 2:
				for _ in _range(2):
					if ans[i - 1] == 0 and i != 1:
						ans[i - 1] = 1
					elif ans[i] == 0:
						ans[i] = 1
					else:
						ans[i + 1] = 1
			else:
				for _ in _range(3):
					if ans[i - 1] == 0 and i != 1:
						ans[i - 1] = 1
					elif ans[i] == 0:
						ans[i] = 1
					else:
						ans[i + 1] = 1
	print(ans.count(1))
solution()


N = int(input())
arr = list(map(int, input().split()))
r = 0
for i in sorted(arr):
	if r > i:
		N -= 1
	else:
		r = max(r + 1, i - 1)
print(N)


n = int(input())
b = list(map(int, input().split(' ')))
cont = 0
peso = 150002
b.sort(reverse=True)
for i in range(0, n):
	if b[i] + 1 < peso:
		peso = b[i] + 1
		cont += 1
	elif b[i] < peso:
		peso = b[i]
		cont += 1
	elif b[i] - 1 < peso and b[i] != 1:
		peso = b[i] - 1
		cont += 1
print(cont)


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())
array = sorted(list(map(int, input().split())))
ans = 0
check = array[n - 1] + 2
for i in range(n - 1, -1, -1):
	if array[i] + 1 < check:
		ans += 1
		check = array[i] + 1
	elif array[i] < check:
		ans += 1
		check = array[i]
	elif array[i] - 1 != 0 and array[i] - 1 < check:
		ans += 1
		check = array[i] - 1
print(ans)


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:
		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))


n = int(input())
lis = sorted(map(int, input().split()))
cur = 1
ans = 0
for i in range(n):
	if cur == lis[i] + 1:
		ans += 1
		cur += 1
	elif cur == lis[i] - 1:
		ans += 1
		cur += 1
	elif cur == lis[i]:
		ans += 1
		cur += 1
	elif cur < lis[i] - 1:
		cur = lis[i]
		ans += 1
print(ans)


from collections import defaultdict
n = int(input())
l = sorted(list(map(lambda x: int(x) - 1, input().split())))
w = defaultdict(lambda : False)
tot = 0
for p in l:
	if p != 0 and (not w[p - 1]):
		w[p - 1] = 1
		tot += 1
	elif not w[p]:
		w[p] = 1
		tot += 1
	elif not w[p + 1]:
		w[p + 1] = 1
		tot += 1
print(tot)


n = int(input())
A = list(map(int, input().split()))
A.sort()
MAX_WEIGHT = 150001
k = 0
count = 0
for i in range(1, MAX_WEIGHT + 1):
	if k >= len(A):
		break
	boxer = A[k]
	if i < boxer - 1:
		i += boxer - 2
		continue
	while i > boxer + 1 and k < len(A) - 1:
		k += 1
		boxer = A[k]
	if i == boxer or i == boxer - 1 or i == boxer + 1:
		count += 1
		k += 1
print(count)


input()
boxers = sorted(map(int, input().split()))
i = 0
num = 0
for x in range(1, 150002):
	while boxers[i] + 1 < x:
		i += 1
		if i >= len(boxers):
			break
	if i >= len(boxers):
		break
	if abs(boxers[i] - x) <= 1:
		num += 1
		i += 1
	if i >= len(boxers):
		break
print(num)


n = int(input())
a = [int(x) for x in input().split(' ')]
a.sort()
team = set()
for boxer in a:
	if boxer > 1 and boxer - 1 not in team:
		team.add(boxer - 1)
	elif boxer not in team:
		team.add(boxer)
	else:
		team.add(boxer + 1)
print(len(team))


n = int(input())
a = list(map(int, input().split()))
ct = {}
for i in range(n):
	ct[a[i]] = ct.get(a[i], 0) + 1
x = sorted(list(set(a)))
for i in x:
	if ct[i] >= 3:
		if i + 1 <= 150001:
			ct[i + 1] = ct.get(i + 1, 0) + 1
		if i - 1 > 0:
			ct[i - 1] = ct.get(i - 1, 0) + 1
	elif ct[i] == 2:
		if i - 1 > 0 and ct.get(i - 1, 0) == 0:
			ct[i - 1] = ct.get(i - 1, 0) + 1
		elif i + 1 <= 150001:
			ct[i + 1] = ct.get(i + 1, 0) + 1
	elif i - 1 > 0 and ct.get(i - 1, 0) == 0:
		ct[i - 1] = 1
		ct[i] = 0
ans = 0
for i in ct:
	if ct[i] > 0:
		ans += 1
print(ans)


n = int(input())
aa = sorted([int(i) for i in input().split()])[::-1]
s = set()
for i in aa:
	if i + 1 not in s and i + 1 != 0:
		s.add(i + 1)
	elif i not in s and i != 0:
		s.add(i)
	elif i - 1 not in s and i - 1 != 0:
		s.add(i - 1)
print(len(s))


n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
curr = int(1000000.0)
for i in range(n - 1, -1, -1):
	if l[i] < curr - 1:
		curr = l[i] + 1
		ans += 1
	elif l[i] == curr - 1:
		curr = l[i]
		ans += 1
	elif l[i] == curr and curr > 1:
		curr = l[i] - 1
		ans += 1
print(ans)


n = int(input())
freq = [0 for _ in range(150002)]
a = list(map(int, input().split()))
a.sort()
for e in a:
	freq[e] += 1
for i in range(n):
	if a[i] > 1 and freq[a[i] - 1] == 0:
		freq[a[i]] -= 1
		freq[a[i] - 1] += 1
	elif freq[a[i]] > 1:
		freq[a[i]] -= 1
		freq[a[i] + 1] += 1
c = 0
for e in freq:
	if e > 0:
		c += 1
print(c)


n = int(input())
array = list(map(int, input().split()))
array.sort()
dp = [True] * 150002
count = 0
for i in range(n):
	if dp[array[i] - 1] and array[i] != 1:
		count += 1
		dp[array[i] - 1] = False
	elif dp[array[i]]:
		count += 1
		dp[array[i]] = False
	elif dp[array[i] + 1]:
		count += 1
		dp[array[i] + 1] = False
print(count)


n = int(input())
d = {}
for i in map(int, input().split()):
	d[i] = d.get(i, 0) + 1
a = list(sorted(d.keys()))
ans = 0
s = set()
for i in sorted(d):
	if d[i] == 1:
		if i in s:
			if i - 1 in s:
				s.add(i + 1)
			else:
				s.add(max(i - 1, 1))
		elif i - 1 in s:
			s.add(i)
		else:
			s.add(max(i - 1, 1))
	elif d[i] == 2:
		if i - 1 in s:
			s.add(i)
			s.add(i + 1)
		else:
			s.add(max(i - 1, 1))
			if i in s:
				s.add(i + 1)
			else:
				s.add(i)
	else:
		s.add(max(i - 1, 1))
		s.add(i)
		s.add(i + 1)
print(len(s))


n = input()
matrix = list(map(lambda x: int(x), input().strip().split()))
flag = [0] * 150002
matrix = sorted(matrix, reverse=True)
for i in matrix:
	if i == 1:
		if not flag[i + 1]:
			flag[i + 1] = 1
		elif not flag[i]:
			flag[i] = 1
	elif not flag[i + 1]:
		flag[i + 1] = 1
	elif not flag[i]:
		flag[i] = 1
	elif not flag[i - 1]:
		flag[i - 1] = 1
print(sum(flag))


def gns():
	return list(map(int, input().split()))
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)


maxp = 150001
n = int(input())
a = list(map(int, input().split(' ')))
b = [0] * (maxp + 1)
c = [0] * (maxp + 1)
for i in a:
	b[i] += 1
for i in range(1, maxp):
	if b[i] == 0:
		continue
	if i > 1 and b[i - 1] + c[i - 1] == 0:
		c[i - 1] = 1
		b[i] -= 1
	if b[i] + c[i] > 0:
		remain = 1 if c[i] == 0 else 0
		c[i + 1] += b[i] - remain
		b[i] = remain
ans = 0
for i in range(maxp + 1):
	if b[i] + c[i] > 0:
		ans += 1
print(ans)


n = int(input())
tmp = input().split()
isAlready = [False] * 150002
isAlready[0] = True
count = 0
for i in range(n):
	tmp[i] = int(tmp[i])
tmp.sort()
for i in range(n):
	boxer = tmp[i]
	if isAlready[boxer - 1] == False:
		isAlready[boxer - 1] = True
		count += 1
	elif isAlready[boxer] == False:
		isAlready[boxer] = True
		count += 1
	elif isAlready[boxer + 1] == False:
		isAlready[boxer + 1] = True
		count += 1
print(count)


n = int(input())
wboxers = input().split()
listboxers = []
for i in range(n):
	listboxers.append(int(wboxers[i]))
listboxers.sort()
answer = 0
mx = 1
for i in range(n):
	if listboxers[i] == mx:
		mx += 1
		answer += 1
	elif listboxers[i] > mx:
		answer += 1
		mx = listboxers[i]
	elif mx - listboxers[i] == 1:
		answer += 1
		mx += 1
print(answer)


n = int(input())
a = list(map(int, input().split()))
a.sort()
s = [0] * (max(a) + 1)
for i in range(n):
	if s[a[i] - 2] == 0 and a[i] > 1:
		s[a[i] - 2] += 1
	elif s[a[i] - 1] == 0:
		s[a[i] - 1] += 1
	elif s[a[i]] == 0:
		s[a[i]] += 1
print(sum(s))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		n = ri()
		a = ria()
		z = [0] * 150005
		z[0] = 1
		d = Counter(a)
		l = sorted(d.keys())
		for i in l:
			if z[i - 1] == 0:
				z[i - 1] = 1
				d[i] -= 1
			if d[i] == 0:
				continue
			if z[i] == 0:
				z[i] = 1
				d[i] -= 1
			if d[i] == 0:
				continue
			if z[i + 1] == 0:
				z[i + 1] = 1
				d[i] -= 1
		ans = 0
		for i in range(1, 150000 + 5):
			if z[i] == 1:
				ans += 1
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


n = int(input())
w_max = 150002
weight = list(map(int, input().split()))
weight = sorted(weight, reverse=True)
answ = []
answ.append(weight[0] + 1)
if weight[0] + 1 < 150002:
	last = weight[0] + 1
else:
	last = weight[0]
last2 = last
weight.remove(weight[0])
count = 1
for i in weight:
	if i + 1 != last and i + 1 < 150002 and (i + 1 != last2) and (i + 1 < answ[-1]):
		answ.append(i + 1)
		count += 1
	elif i != last and i != last2 and (i < answ[-1]):
		answ.append(i)
		count += 1
	elif i - 1 != last and i - 1 > 0 and (i - 1 != last2) and (i - 1 < answ[-1]):
		answ.append(i - 1)
		count += 1
	last = answ[-1]
	last2 = answ[-2]
print(count)


n = int(input())
teamsize = 0
boxers = list(map(int, input().split()))
countin = [0] * 150002
countout = [0] * 150002
for boxer in boxers:
	countin[boxer] += 1
for i in range(1, 150001):
	if countin[i] and countout[i - 1] == 0 and (i > 1):
		teamsize += 1
		countin[i] -= 1
		countout[i - 1] = 1
	if countin[i] and countout[i] == 0:
		teamsize += 1
		countin[i] -= 1
		countout[i] += 1
	if countin[i] and countout[i + 1] == 0:
		teamsize += 1
		countin[i] -= 1
		countout[i + 1] += 1
print(teamsize)


N = int(input())
A = [int(i) for i in input().split()]
A.sort()
st = set()
for i in A:
	if i - 1 not in st and i != 1:
		st.add(i - 1)
		continue
	if i not in st:
		st.add(i)
		continue
	if i + 1 not in st:
		st.add(i + 1)
		continue
print(len(st))


n = int(input())
b = list(map(int, input().split()))
b.sort(reverse=True)
used = set()
res = 0
for i in b:
	if not i + 1 in used:
		res += 1
		used.add(i + 1)
		continue
	if not i in used:
		res += 1
		used.add(i)
		continue
	if not i - 1 in used and i > 1:
		res += 1
		used.add(i - 1)
		continue
print(res)


n = int(input())
a = list(map(int, input().split()))
a.sort()
s = set()
i = 0
while i < n:
	k = i
	while k + 1 < n and a[k + 1] == a[i]:
		k += 1
	if k - i + 1 == 1:
		if a[i] - 1 > 0 and a[i] - 1 not in s:
			s.add(a[i] - 1)
		elif a[i] in s:
			s.add(a[i] + 1)
		else:
			s.add(a[i])
	elif k - i + 1 == 2:
		s.add(a[i])
		if a[i] - 1 > 0 and a[i] - 1 not in s:
			s.add(a[i] - 1)
		else:
			s.add(a[i] + 1)
	elif k - i + 1 > 2:
		s.add(a[i])
		if a[i] - 1 > 0:
			s.add(a[i] - 1)
		s.add(a[i] + 1)
	i = k + 1
print(len(s))


n = int(input())
arr = [int(k) for k in input().split()]
arr.sort(reverse=True)
ans = 1
dic = {}
dic[arr[0] + 1] = 1
for i in range(1, n):
	if arr[i] + 1 not in dic:
		dic[arr[i] + 1] = 1
		ans += 1
	elif arr[i] not in dic:
		dic[arr[i]] = 1
		ans += 1
	elif arr[i] - 1 != 0 and arr[i] - 1 not in dic:
		dic[arr[i] - 1] = 1
		ans += 1
print(ans)


def arr_inp():
	return [int(x) for x in input().split()]
from collections import *
(n, a, unique) = (int(input()), sorted(arr_inp()), defaultdict(int))
a[-1] += 1
unique[a[-1]] = 1
for (k, i) in enumerate(a[:-1]):
	if unique[i - 1] == 0 and i > 1:
		unique[i - 1] += 1
	elif unique[i] == 0:
		unique[i] += 1
	elif unique[i + 1] == 0 and i < 150001:
		unique[i + 1] += 1
print(len(list(filter(lambda x: x, unique.values()))))


def int_multiple():
	return [int(c) for c in input().split()]

def int_single():
	return int(input())

def str_multiple():
	return [c for c in input().split()]

def str_single():
	return input()
n = int_single()
l = int_multiple()
l = sorted(l)
team = 0
avail = 1
for i in range(n):
	if l[i] - 1 >= avail:
		team += 1
		avail = l[i]
	elif l[i] >= avail:
		team += 1
		avail = l[i] + 1
	elif l[i] + 1 >= avail:
		team += 1
		avail = l[i] + 2
	else:
		continue
print(team)


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
n = int(input())
a = list(mapi())
a.sort()
pst = -float('inf')
res = 0
for i in range(n):
	if 0 < a[i] - 1 > pst:
		res += 1
		pst = a[i] - 1
	elif a[i] > pst:
		res += 1
		pst = a[i]
	elif a[i] + 1 > pst:
		res += 1
		pst = a[i] + 1
print(res)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
a = sorted(list(map(int, input().split())))
vis = set()
for i in a:
	if i != 1 and i - 1 not in vis:
		vis.add(i - 1)
	elif i not in vis:
		vis.add(i)
	elif i + 1 not in vis:
		vis.add(i + 1)
print(len(vis))


n = int(input())
x = list(map(int, input().split()))
x.sort()
ans = 0
curmax = 0
for i in range(n):
	if x[i] - 1 > curmax:
		curmax = x[i] - 1
		ans += 1
	elif x[i] - 1 == curmax:
		curmax = x[i]
		ans += 1
	elif x[i] + 1 > curmax:
		curmax = x[i] + 1
		ans += 1
print(ans)


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)


n = int(input())
l = list(map(int, input().split()))
l.sort()
d = {}
t = 0
for i in l:
	if i > 1:
		if i - 1 not in d:
			d[i - 1] = 1
			t += 1
			continue
	if i not in d:
		d[i] = 1
		t += 1
		continue
	if i + 1 <= 150001:
		if i + 1 not in d:
			d[i + 1] = 1
			t += 1
print(t)


a = int(input())
b = sorted(map(int, input().split()))
c = set()
for i in b:
	if i - 1 not in c and i - 1 > 0:
		c.add(i - 1)
	elif i not in c:
		c.add(i)
	else:
		c.add(i + 1)
print(len(c))


res = 0
n = int(input())
a = [int(i) for i in input().split()]
b = [False for i in range(150005)]
a.sort()
for i in range(n - 1, -1, -1):
	if not b[a[i] + 1]:
		res += 1
		b[a[i] + 1] = True
	elif not b[a[i]]:
		res += 1
		b[a[i]] = True
	elif not b[a[i] - 1] and a[i] != 1:
		res += 1
		b[a[i] - 1] = True
print(res)


n = int(input())
dat = list(map(int, input().split()))
orig1 = [0] * 150010
orig2 = [0] * 150020
for i in range(n):
	orig1[dat[i]] += 1
for i in range(1, 150001):
	if i != 1 and orig2[i - 1] == 0 and (orig1[i] != 0):
		orig1[i] -= 1
		orig2[i - 1] += 1
	if orig2[i] == 0 and orig1[i] != 0:
		orig1[i] -= 1
		orig2[i] += 1
	if orig2[i + 1] == 0 and orig1[i] != 0:
		orig1[i] -= 1
		orig2[i + 1] += 1
res = 0
for i in range(1, 150010):
	if orig2[i] != 0:
		res += 1
print(res)


num = int(input())
inputlist = list(map(int, input().split(' ')))
inputlist.sort()
boxersizes = set()
for i in inputlist:
	if i - 1 not in boxersizes and i != 1:
		boxersizes.add(i - 1)
	elif i not in boxersizes:
		boxersizes.add(i)
	elif i + 1 not in boxersizes:
		boxersizes.add(i + 1)
	else:
		continue
print(len(boxersizes))


n = int(input())
ln = [int(i) for i in input().split(' ')]
ln = sorted(ln)[::-1]
w = 10000000000
n = 0
for i in range(0, len(ln)):
	if ln[i] + 1 < w:
		n += 1
		w = ln[i] + 1
	elif ln[i] < w:
		n += 1
		w = ln[i]
	elif ln[i] - 1 < w:
		n += 1
		w = ln[i] - 1
		if w == 0:
			n -= 1
			break
print(n)


import math
import sys
from collections import defaultdict

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	next_min = 1
	res = 0
	for i in range(n):
		if a[i] == next_min:
			res += 1
			next_min += 1
		elif a[i] < next_min and a[i] + 1 == next_min:
			res += 1
			next_min += 1
		elif a[i] > next_min:
			res += 1
			next_min = a[i]
	print(res)
main()


listOfResult = []
count = int(input())
weight = list(map(int, input().rstrip().split()))
weight.sort()
hiya = 0
prev = 0
for i in weight:
	if i - 1 > prev:
		hiya += 1
		prev = i - 1
	elif i > prev:
		hiya += 1
		prev = i
	elif i + 1 > prev:
		hiya += 1
		prev = i + 1
print(hiya)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
l = I()
a = [0] * 200000
b = [0] * 200000
for i in l:
	a[i] += 1
if a[1] > 1:
	a[2] += 1
	a[1] -= 1
for i in range(150000, 1, -1):
	if a[i] and (not (a[i + 1] or b[i + 1])):
		b[i + 1] += 1
		a[i] -= 1
	if a[i] > 1 or (a[i] and b[i]):
		a[i] -= 1
		b[i - 1] += 1
print(sum([a[i] > 0 or b[i] > 0 for i in range(200000)]))


from collections import defaultdict
n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
Dict = defaultdict(int)
for i in range(n):
	if arr[i] > 1 and Dict[arr[i] - 1] == 0:
		Dict[arr[i] - 1] += 1
	elif Dict[arr[i]] == 0:
		Dict[arr[i]] += 1
	elif Dict[arr[i] + 1] == 0:
		Dict[arr[i] + 1] += 1
print(len(list(Dict.keys())))


from collections import defaultdict
x = int(input())
a = list(map(int, input().split()))
a.sort()
s = set()
a = a[::-1]
d = defaultdict(int)
for i in a:
	if d[i + 1] == 0:
		s.add(i + 1)
		d[i + 1] = 1
	elif d[i] == 0:
		s.add(i)
		d[i] = 1
	elif d[i - 1] == 0 and i - 1 != 0:
		s.add(i - 1)
		d[i - 1] = 1
print(len(s))


from sys import stdin
n = int(stdin.readline())
m = list((int(i) for i in stdin.readline().split()))
count = 0
team = list((0 for i in range(0, 150002)))
for i in m:
	team[i] += 1
if team[1] == 1:
	count += 1
elif team[1] >= 2:
	count += 1
	team[2] += 1
for j in range(2, 150002):
	if team[j] == 1:
		if team[j - 1] == 0:
			team[j] -= 1
			count += 1
		else:
			count += 1
	elif team[j] == 2:
		if team[j - 1] == 0:
			team[j] -= 1
			count += 1
		else:
			team[j + 1] += 1
		count += 1
	elif team[j] >= 3:
		if team[j - 1] == 0:
			team[j] -= 1
			count += 1
		count += 1
		team[j + 1] += 1
		team[j] -= 1
print(count)


while True:
	amount = int(input())
	number = input()
	num1 = [int(val) for val in number.split(' ')]
	if len(num1) == amount:
		break
num1.sort()
box = set()
for x in num1:
	if x - 1 > 0 and x - 1 not in box:
		box.add(x - 1)
	elif x not in box:
		box.add(x)
	elif x + 1 not in box:
		box.add(x + 1)
print(len(box))


amount = int(input())
s = list(map(int, input().split()))
s.sort()
uniq = set()
for elem in s:
	if elem - 1 not in uniq and elem != 1:
		uniq.add(elem - 1)
	elif elem not in uniq:
		uniq.add(elem)
	else:
		uniq.add(elem + 1)
print(len(uniq))


n = int(input())
l = list(map(int, input().split()))
l1 = set()
l.sort()
for i in range(0, n):
	if l[i] != 1 and l[i] - 1 not in l1:
		l1.add(l[i] - 1)
		continue
	if l[i] not in l1:
		l1.add(l[i])
		continue
	if l[i] + 1 not in l1:
		l1.add(l[i] + 1)
print(len(l1))


import bisect
from bisect import bisect_left

def BinarySearch(a, x):
	i = bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
c = []
for i in range(len(a)):
	if a[i] - 1 > 0:
		if BinarySearch(c, a[i] - 1) == -1:
			c.append(a[i] - 1)
		elif BinarySearch(c, a[i]) == -1:
			c.append(a[i])
		elif BinarySearch(c, a[i] + 1) == -1:
			c.append(a[i] + 1)
	elif BinarySearch(c, a[i]) == -1:
		c.append(a[i])
	elif BinarySearch(c, a[i] + 1) == -1:
		c.append(a[i] + 1)
print(len(set(c)))


N = int(input())
s = [int(x) for x in input().split()]
arr = sorted(s)
pos = [0] * 150005
for i in range(0, len(arr)):
	if pos[arr[i] - 1] == 0 and arr[i] - 1 > 0:
		pos[arr[i] - 1] = 1
	elif pos[arr[i]] == 0:
		pos[arr[i]] = 1
	elif pos[arr[i] + 1] == 0 and arr[i] + 1 < 150002:
		pos[arr[i] + 1] = 1
c = 0
for i in range(0, len(pos)):
	if pos[i] == 1:
		c += 1
print(c)


n = input()
boxerList = list(map(int, input().split()))
boxerList.sort()
boxerSet = set()
for i in boxerList:
	if i - 1 not in boxerSet and i != 1:
		boxerSet.add(i - 1)
	elif i not in boxerSet:
		boxerSet.add(i)
	elif i + 1 not in boxerSet:
		boxerSet.add(i + 1)
	else:
		continue
print(len(boxerSet))


def readInts():
	return [int(s) for s in input().split(' ')]

def main():
	n = readInts()[0]
	A = readInts()
	A.sort()
	s = set()
	for a in A:
		if a > 1 and a - 1 not in s:
			s.add(a - 1)
		elif a not in s:
			s.add(a)
		elif a + 1 not in s:
			s.add(a + 1)
	print(len(s))
main()


n = int(input())
l = list(map(int, input().split()))
l.sort()
s = set()
for ele in l:
	if ele - 1 not in s and ele - 1 > 0:
		s.add(ele - 1)
	elif ele not in s:
		s.add(ele)
	elif ele + 1 not in s:
		s.add(ele + 1)
print(len(s))


import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inf = float('inf')
en = lambda x: list(enumerate(x))
ceil_ = lambda a, b: (a + b - 1) // b
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
n = ii()
arr = rr()
arr.sort(reverse=True)
brr = [inf]
for i in arr:
	if i + 1 < brr[-1]:
		brr += (i + 1,)
	elif i < brr[-1]:
		brr += (i,)
	elif i - 1 < brr[-1] and i > 1:
		brr += (i - 1,)
print(len(brr) - 1)


n = int(input())
a = list(map(int, input().split()))
b = [None] + [0] * (max(a) + 1)
d = [False] + [False] * (max(a) + 1)
for x in a:
	b[x] += 1
if b[1] > 1 and d[2] == False:
	b[1] -= 1
	d[1] = True
	d[2] = True
elif b[1] == 1:
	d[1] = True
for i in range(2, max(a) + 1):
	if b[i] >= 1 and d[i - 1] == False:
		d[i - 1] = True
		b[i] -= 1
	if b[i] >= 1 and d[i] == False:
		d[i] = True
		b[i] -= 1
	if b[i] >= 1 and d[i + 1] == False:
		d[i + 1] = True
		b[i] -= 1
print(len([x for x in range(1, max(a) + 2) if d[x] == True]))


def max_team(n, weights):
	weights.sort(reverse=True)
	prev_weights = 10000000000
	ans = 0
	for i in range(n):
		curr_weights = weights[i]
		if curr_weights + 1 < prev_weights:
			ans += 1
			prev_weights = curr_weights + 1
		elif curr_weights < prev_weights:
			ans += 1
			prev_weights = curr_weights
		elif curr_weights - 1 < prev_weights:
			if curr_weights - 1 != 0:
				ans += 1
				prev_weights = curr_weights - 1
	return ans
n = int(input())
weights = list(map(int, input().split()))
print(max_team(n, weights))


import sys
import math
import bisect

def main():
	n = int(input())
	A = list(map(int, input().split()))
	s = set()
	A.sort()
	for a in A:
		if a - 1 >= 1 and a - 1 not in s:
			s.add(a - 1)
		elif a not in s:
			s.add(a)
		elif a + 1 not in s:
			s.add(a + 1)
	print(len(s))
main()


n = int(input())
s = input()
list = s.split()
for i in range(n):
	list[i] = int(list[i])
list.sort()
block = [0] * 160000
block[0] = 1
for i in list:
	if block[i - 1] == 0:
		block[i - 1] += 1
	elif block[i] == 0:
		block[i] += 1
	elif block[i + 1] == 0:
		block[i + 1] += 1
print(block.count(1) - 1)


import math
from functools import reduce
q = 1
for _ in range(q):
	n = int(input())
	p = list(map(lambda x: int(x), input().split()))
	mx = max(p)
	c = [0] * (mx + 2)
	for i in p:
		c[i] += 1
	count = 0
	for i in range(1, mx + 1):
		if c[i] == 0 and c[i + 1] > 0:
			c[i] += 1
			c[i + 1] -= 1
		if c[i] > 1:
			c[i + 1] += 1
			c[i] -= 1
	if c[mx] > 1:
		c[mx + 1] += 1
	print(reduce(lambda x, y: x + (1 if y > 0 else 0), c))


ll = lambda : list(map(int, input().split()))
testcases = 1
for testcase in range(testcases):
	[n] = ll()
	a = ll()
	a.sort()
	vis = [0] * 150005
	for i in a:
		if i == 1 and vis[i]:
			vis[2] = 1
		if not vis[i - 1] and i - 1 != 0:
			vis[i - 1] = 1
		elif vis[i - 1] and (not vis[i]):
			vis[i] = 1
		elif vis[i] and vis[i - 1]:
			vis[i + 1] = 1
		else:
			vis[i] = 1
	c = 0
	for i in range(1, 150005):
		if vis[i] == 1:
			c += 1
	print(c)


a = int(input())
A = list(map(int, input().split()))
A.sort()
k = 0
for i in range(a):
	A[i] += 1
q = 0
A.append(10 ** 6)
for i in range(a):
	if A[i] == A[i + 1]:
		if q + 2 < A[i]:
			A[i] -= 2
			q = A[i]
			k += 1
		elif q + 1 < A[i]:
			A[i] -= 1
			q = A[i]
			k += 1
	elif q + 2 < A[i]:
		A[i] -= 2
		q = A[i]
		k += 1
	elif q + 1 < A[i]:
		A[i] -= 1
		q = A[i]
		k += 1
	else:
		q = A[i]
		k += 1
print(k)


n = int(input())
nums = [int(x) for x in input().split()]
nums = sorted(nums, reverse=True)
cnt = 1
cur = nums[0] + 1
for x in nums[1:]:
	if x + 1 < cur:
		cur = x + 1
		cnt += 1
	elif x + 1 == cur:
		cur = x
		cnt += 1
	elif x == cur and x != 1:
		cur = x - 1
		cnt += 1
print(cnt)


from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
lst = float('inf')
ans = 0
for i in range(n):
	cur = -1
	for j in (1, 0, -1):
		if a[i] + j > 0 and a[i] + j < lst:
			cur = a[i] + j
			break
	if cur == -1:
		continue
	ans += 1
	lst = cur
print(ans)


n = int(input())
a = sorted(list(map(int, input().split())))
if a[0] > 1:
	a[0] = a[0] - 1
for i in range(1, n):
	if a[i] > a[i - 1] + 1 and a[i] > 1:
		a[i] = a[i] - 1
	elif a[i] <= a[i - 1]:
		a[i] = a[i] + 1
print(len(set(a)))


from sys import stdin, stdout
input = stdin.readline
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
ans = [0] * 150002
for i in arr:
	if ans[i - 1] != 1 and i - 1 != 0:
		ans[i - 1] = 1
	elif ans[i] != 1:
		ans[i] = 1
	elif ans[i + 1] != 1:
		ans[i + 1] = 1
print(sum(ans))


n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
dx = (1, 0, -1)
lst = 150002
ans = 0
for x in a:
	cur = -1
	for t in dx:
		if 0 < x + t < lst:
			cur = x + t
			break
	if cur == -1:
		continue
	lst = cur
	ans += 1
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
store = [0 for i in range(150005)]
for i in a:
	store[i] += 1
c = 0
for i in range(1, 150002):
	if i > 1 and store[i - 1]:
		c += 1
		store[i - 1] -= 1
	elif store[i]:
		c += 1
		store[i] -= 1
	elif store[i + 1]:
		c += 1
		store[i + 1] -= 1
print(c)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		a.sort()
		t = 0
		r = 0
		for c in a:
			for k in range(c - 1, c + 2):
				if k > t:
					r += 1
					t = k
					break
		rr.append(r)
	return JA(rr, '\n')
print(main())


n = int(input())
w = sorted(list(map(int, input().split())))

def f(x, res):
	if x > res[-1] or (x != res[-1] and x != res[-2]):
		res.append(x)
		return 1
	return 0
i = 0
res = [0, 0]
while i < n:
	pred = w[i]
	c = 0
	while i < n and pred == w[i]:
		i += 1
		c += 1
	nb = 0
	for s in [-1, 0, 1]:
		nb += f(pred + s, res)
		if nb == c:
			break
print(len(res) - 2)


N = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
i = 0
count = 0
prev = arr[0] + 10
while i < N:
	if arr[i] + 1 < prev:
		count += 1
		prev = arr[i] + 1
	elif arr[i] < prev:
		prev = arr[i]
		count += 1
	elif arr[i] - 1 < prev and arr[i] - 1 > 0:
		count += 1
		prev = arr[i] - 1
	i += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
b = [0] * 150002
b[0] = 1
a.sort()
ans = n
for i in range(n):
	if b[a[i] - 1] == 1:
		if b[a[i]] == 1:
			if b[a[i] + 1] == 1:
				ans -= 1
			else:
				b[a[i] + 1] = 1
		else:
			b[a[i]] = 1
	else:
		b[a[i] - 1] = 1
print(ans)


n = int(input())
arr = list(map(int, input().split(' ')))
arr.sort()
arr[n - 1] += 1
for i in range(n - 2, -1, -1):
	if arr[i + 1] - arr[i] == 1:
		continue
	if arr[i + 1] - arr[i] > 1:
		arr[i] += 1
	elif i > 0 and arr[i - 1] != arr[i]:
		if arr[i] != 1:
			arr[i] -= 1
	elif arr[i] > 1 and i == 0:
		arr[i] -= 1
ans = n
for i in range(1, n):
	if arr[i] == arr[i - 1]:
		ans -= 1
print(ans)


N = int(input())
lis = list(map(int, input().split()))
lis.sort()
length = len(lis)
output = 1
if lis[0] > 1:
	lis[0] -= 1
for i in range(1, length):
	if lis[i - 1] + 1 < lis[i]:
		lis[i] -= 1
		output += 1
		continue
	if lis[i - 1] > lis[i]:
		lis[i] = lis[i - 1]
		continue
	if lis[i - 1] == lis[i]:
		lis[i] += 1
		output += 1
		continue
	output += 1
print(output)


n = int(input())
weights = list(map(int, input().split()))
weights.sort(reverse=True)
last = weights[0] + 10
for i in range(n):
	if weights[i] + 1 < last:
		weights[i] += 1
	elif weights[i] + 1 > last and weights[i] - 1 > 0:
		weights[i] -= 1
	last = weights[i]
print(len(set(weights)))


n = int(input())
A = list(map(int, input().split()))
B = [False] * 150001
for i in range(n):
	A[i] -= 1
A.sort()
i = 0
ans = 0
for j in range(150000):
	end = i
	while end < n and A[end] == j:
		end += 1
	cnt = end - i
	if j > 0 and (not B[j - 1]) and (cnt > 0):
		B[j - 1] = True
		cnt -= 1
		ans += 1
	if not B[j] and cnt > 0:
		B[j] = True
		cnt -= 1
		ans += 1
	if cnt > 0:
		B[j + 1] = True
		cnt -= 1
		ans += 1
	i = end
print(ans)


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
n = int(rd())
a = list(rrd())
have = [0] * 150004
tot = [0] * 150004
for i in a:
	tot[i] += 1
for (i, v) in enumerate(tot):
	if not v:
		continue
	if i - 1 > 0 and (not have[i - 1]):
		have[i - 1] = 1
		v -= 1
	if v and (not have[i]):
		have[i] = 1
		v -= 1
	if v and (not have[i + 1]):
		have[i + 1] = 1
print(sum(have))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	temp = set()
	dic = Counter(a)
	for x in sorted(dic.keys()):
		if dic[x] >= 3:
			temp.add(x)
			temp.add(x + 1)
			dic[x + 1] += 1
			if x - 1 != 0:
				temp.add(x - 1)
		elif dic[x] == 1:
			if x - 1 in temp:
				temp.add(x)
			elif x - 1 != 0:
				temp.add(x - 1)
			else:
				temp.add(x)
		elif dic[x] == 2:
			if x - 1 in temp:
				temp.add(x)
				temp.add(x + 1)
				dic[x + 1] += 1
			else:
				if x - 1 != 0:
					temp.add(x - 1)
				else:
					temp.add(x + 1)
					dic[x + 1] += 1
				temp.add(x)
	print(len(temp))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
now = max(1, a[0] - 1)
for i in range(1, n):
	if a[i] - now > 1:
		now = a[i] - 1
		ans += 1
	elif a[i] - now == 1:
		now = a[i]
		ans += 1
	elif a[i] == now:
		now = a[i] + 1
		ans += 1
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
x = [0] * 150002
x[0] = 1
for i in range(n):
	if x[a[i] - 1] != 1:
		x[a[i] - 1] += 1
	elif x[a[i]] == 1:
		if x[a[i] + 1] == 0:
			x[a[i] + 1] = 1
	else:
		x[a[i]] = 1
print(sum(x) - 1)


N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[0] != 1:
	A[0] -= 1
ans = 1
for i in range(N - 1):
	if A[i] + 1 < A[i + 1]:
		A[i + 1] -= 1
		ans += 1
	elif A[i] < A[i + 1]:
		ans += 1
	elif A[i] == A[i + 1]:
		A[i + 1] += 1
		ans += 1
	elif A[i] >= A[i + 1]:
		A[i + 1] = A[i]
print(ans)


n = int(input())
a = sorted(list(map(int, input().split())))
b = [0 for k in range(150010)]
for e in a:
	if e == 1:
		if b[1] == 0:
			b[1] = 1
		elif b[1] == 1 and b[2] == 0:
			b[2] = 1
	elif b[e - 1] == 0:
		b[e - 1] = 1
	elif b[e - 1] == 1 and b[e] == 0:
		b[e] = 1
	elif b[e - 1] == 1 and b[e] == 1 and (b[e + 1] == 0):
		b[e + 1] = 1
print(sum(b))


import sys
n = int(input())
boxers = list(map(int, next(sys.stdin).split(' ')))
result = 0
max_boxer = 200000
boxers.sort(reverse=True)
for b in boxers:
	if b + 1 < max_boxer:
		max_boxer = b + 1
		result += 1
	elif b < max_boxer:
		max_boxer = b
		result += 1
	elif 0 < b - 1 < max_boxer:
		max_boxer = b - 1
		result += 1
print(result)


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


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
d = Counter(l)
m = {}
ans = []
s = set(l)
k = list(s)
k.sort()
for t in k:
	val1 = m.get(t - 1, -1)
	val = m.get(t, -1)
	val2 = m.get(t + 1, -1)
	if t == 1:
		if d[t] == 1:
			if val != 1:
				ans.append(t)
				m[t] = 1
			elif val2 != 1:
				ans.append(t + 1)
				m[t + 1] = 1
		if d[t] == 2:
			if val != 1:
				ans.append(t)
				m[t] = 1
			if val2 != 1:
				ans.append(t + 1)
				m[t + 1] = 1
		if d[t] >= 3:
			if val != 1:
				ans.append(t)
				m[t] = 1
			if val2 != 1:
				ans.append(t + 1)
				m[t + 1] = 1
	else:
		if d[t] == 1:
			if val1 != 1:
				ans.append(t - 1)
				m[t - 1] = 1
			elif val != 1:
				ans.append(t)
				m[t] = 1
			elif val2 != 1:
				ans.append(t + 1)
				m[t + 1] = 1
		if d[t] == 2:
			c = 0
			if val1 != 1:
				ans.append(t - 1)
				m[t - 1] = 1
				c += 1
			if val != 1:
				ans.append(t)
				m[t] = 1
				c += 1
			if val2 != 1 and c < 2:
				ans.append(t + 1)
				m[t + 1] = 1
		if d[t] >= 3:
			if val1 != 1:
				ans.append(t - 1)
				m[t - 1] = 1
			if val != 1:
				ans.append(t)
				m[t] = 1
			if val2 != 1:
				ans.append(t + 1)
				m[t + 1] = 1
print(len(set(ans)))


n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(1, len(a)):
	a[i] += 1
a[0] = max(1, a[0] - 1)
for i in range(1, len(a)):
	if a[i] - 2 > a[i - 1]:
		a[i] = a[i] - 2
	elif a[i] - 1 > a[i - 1]:
		a[i] = a[i] - 1
	else:
		pass
c = 1
x = a[0]
for i in a:
	if i == x:
		pass
	else:
		c += 1
		x = i
print(c)


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
A.sort()
cur_weight = max(A[0] - 1, 1)
ans = 1
for i in range(1, n):
	diff = A[i] - cur_weight
	if diff == 0:
		cur_weight = A[i] + 1
		ans += 1
	elif diff == 1:
		cur_weight = A[i]
		ans += 1
	elif diff > 1:
		cur_weight = A[i] - 1
		ans += 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort()
d = {0: 0}
for i in l:
	try:
		k = d[i - 1]
		try:
			k1 = d[i]
			try:
				k = d[i + 1]
			except KeyError:
				d[i + 1] = 0
		except KeyError:
			d[i] = 1
	except KeyError:
		d[i - 1] = 0
print(len(d.keys()) - 1)


import sys
import math
import operator as op
from functools import reduce
from bisect import *
from collections import deque

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().split()]

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
N = int(1000000.0) + 10
fenwick = [0] * N

def add(i, x, n):
	while i < n:
		fenwick[i] += x
		i = i | i + 1

def fsum(i, n):
	res = 0
	while i >= 0:
		res += fenwick[i]
		i = (i & i + 1) - 1
	return res

def fsum_range(i, j, n):
	return fsum(j, n) - fsum(i - 1, n)
mod = int(1000000000.0) + 7
mod2 = 998244353
t = 1
for i in range(t):
	n = read_int()
	a = read_int_line()
	a.sort(reverse=True)
	prev = 1000000000.0
	ans = 0
	for i in a:
		if i + 1 < prev:
			ans += 1
			prev = i + 1
		elif i < prev:
			ans += 1
			prev = i
		elif i - 1 < prev and i - 1 > 0:
			ans += 1
			prev = i - 1
	print(ans)


input()
l = list(map(int, input().split()))
d = {}
s = set()
latest = set()
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
		s.add(i)
t = sorted(s)
for i in t:
	if d[i] > 2:
		s.add(i + 1)
		latest.add(i + 1)
		if i - 1 > 0:
			s.add(i - 1)
	elif d[i] == 2:
		if i - 1 in s or i - 1 == 0:
			s.add(i + 1)
			latest.add(i + 1)
		else:
			s.add(i - 1)
	elif i - 1 not in s and i - 1 > 0:
		s.add(i - 1)
		if i not in latest:
			s.discard(i)
	elif i in latest:
		s.add(i + 1)
		latest.add(i + 1)
print(len(s))


num = int(input())
arr = [int(x) for x in input().split()]
unique = set()
left = []
arr.sort(reverse=True)
for ele in arr:
	if ele + 1 not in unique:
		unique.add(ele + 1)
	elif ele not in unique:
		unique.add(ele)
	elif ele - 1 not in unique and ele - 1 != 0:
		unique.add(ele - 1)
print(len(unique))


import sys
input = sys.stdin.readline

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math, itertools

def solve():
	N = getInt()
	A = getInts()
	A.sort(reverse=True)
	used = set()
	while A:
		x = A.pop()
		if x - 1 not in used and x > 1:
			used.add(x - 1)
		elif x not in used:
			used.add(x)
		elif x + 1 not in used:
			used.add(x + 1)
	return len(used)
print(solve())


import sys
n = int(next(sys.stdin))
team = set()
weights = sorted(list(map(int, next(sys.stdin).split(' '))), reverse=True)
max_weight = None
ans = 0
for weight in weights:
	if max_weight is None:
		max_weight = weight + 1
		ans += 1
		continue
	if weight + 1 < max_weight:
		ans += 1
		max_weight = weight + 1
	elif weight < max_weight:
		ans += 1
		max_weight = weight
	elif weight - 1 < max_weight and weight - 1 > 0:
		ans += 1
		max_weight = weight - 1
print(ans)


from collections import defaultdict
n = int(input())
x = [int(item) for item in input().split(' ')]
t = defaultdict(lambda : 0)
for item in x:
	t[item] += 1
s = set()
for item in sorted(t.keys()):
	f = t[item]
	for a in range(-1, 2):
		nn = item + a
		if nn not in s and nn > 0:
			s.add(nn)
			f -= 1
			if f == 0:
				break
print(len(s))


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


n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
s = set()
for i in range(len(a)):
	if a[i] + 1 not in s:
		s.add(a[i] + 1)
	elif a[i] not in s:
		s.add(a[i])
	elif a[i] > 1:
		s.add(a[i] - 1)
print(len(s))


def prcess(A, n):
	C = A.copy()
	C.sort()
	A.append(-10000000000.0)
	A.append(10000000000.0)
	A.sort()
	temp = 1
	B = {}
	for i in range(1, len(A)):
		if A[i - 1] == A[i]:
			temp += 1
		else:
			B[A[i - 1]] = temp
			temp = 1
	A[-2] += 1
	B[10000000000.0] = 1
	for i in reversed(range(1, len(A) - 2)):
		if A[i] + 1 < A[i + 1]:
			A[i] += 1
	for i in range(1, len(A) - 2):
		if A[i - 1] + 1 < A[i] and A[i] > 1:
			A[i] -= 1
	res = 0
	for i in range(1, len(A) - 1):
		if A[i] != A[i + 1] and A[i] != 0:
			res += 1
	return res
n = int(input())
A = [int(x) for x in input().split()]
print(prcess(A, n))


n = int(input())
a = list(map(int, input().split()))
a.sort()
present = [0] * 150005
for i in range(n):
	k = a[i]
	if k > 1 and present[k - 1] == 0:
		present[k - 1] = 1
	elif present[k] == 0:
		present[k] = 1
	else:
		present[k + 1] = 1
count = 0
for i in range(150005):
	count += present[i]
print(count)


from collections import deque
I = lambda : map(int, input().split())
n = int(input())
a = sorted(list(I()))
a = deque(a)
a.appendleft(0)
res = 0
for i in range(1, n + 1):
	if a[i] < a[i - 1]:
		a[i] = a[i - 1]
		continue
	if a[i] == a[i - 1]:
		a[i] += 1
	elif a[i] - 1 != a[i - 1]:
		a[i] -= 1
	res += 1
print(res)


n = int(input())
list = [int(i) for i in input().split()]
list.sort()
if list[0] > 1:
	list[0] -= 1
i = 1
while i < len(list):
	if list[i] == list[i - 1]:
		list[i] += 1
		i += 1
	elif list[i] > list[i - 1]:
		if list[i] - list[i - 1] > 1:
			list[i] -= 1
		i += 1
	elif list[i] < list[i - 1]:
		del list[i]
print(len(set(list)))


n = int(input())
l = list(map(int, input().split()))
l.sort()
from collections import Counter
c = Counter(l)
l1 = list(set(l))
x = len(l1)
i = 0
j = 0
while i < x - 1:
	a = c[l1[i]] - 1
	while l1[i] + 1 == l1[i + 1]:
		if c[l1[i + 1]] > 1:
			a += c[l1[i + 1]] - 1
		i += 1
		if i == x - 1:
			break
	if a == 1:
		if l1[j] != 1:
			if c[l1[j] - 1] == 0:
				c[l1[j] - 1] += 1
				a -= 1
		if a == 1:
			if c[l1[i] + 1] == 0:
				c[l1[i] + 1] += 1
	elif a >= 2:
		if l1[j] != 1:
			if c[l1[j] - 1] == 0:
				c[l1[j] - 1] += 1
		if c[l1[i] + 1] == 0:
			c[l1[i] + 1] += 1
	i += 1
	j = i
if c[l1[-1]] == 2:
	if c[l1[-1] - 1] == 0 and l1[-1] != 1:
		c[l1[-1] - 1] += 1
	else:
		c[l1[-1] + 1] += 1
elif c[l1[-1]] > 2:
	if c[l1[-1] - 1] == 0 and l1[-1] != 1:
		c[l1[-1] - 1] += 1
	if c[l1[-1] + 1] == 0:
		c[l1[-1] + 1] += 1
print(len(c))


from sys import stdin

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())
n = ii()
a = li()
a.sort(reverse=True)
m = max(a)
p = [1] * (m + 2)
for i in range(n):
	if p[a[i] + 1]:
		p[a[i] + 1] = 0
	elif p[a[i]]:
		p[a[i]] = 0
	elif p[a[i] - 1]:
		p[a[i] - 1] = 0
print(p[1:].count(0))


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)


def main():
	n = input()
	mans = list(map(int, input().split()))
	mans.sort(reverse=True)
	lst = 150002
	count = 0
	for man in mans:
		if man + 1 < lst:
			lst = man + 1
			count += 1
		elif man < lst:
			lst = man
			count += 1
		elif 0 < man - 1 < lst:
			lst = man - 1
			count += 1
	print(count)
main()


import math
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
	elif 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)


n = int(input())
brr = list(map(int, input().split()))
if n < 4:
	print(n)
else:
	dic = {}
	for i in brr:
		dic[i] = 0
	for i in brr:
		if dic[i] < 3:
			dic[i] += 1
	arr = []
	for i in dic:
		for j in range(dic[i]):
			arr.append(i)
	arr.sort()
	ans = 0
	if arr[0] == 1:
		ans = 1
	else:
		arr[0] -= 1
		ans = 1
	n = len(arr)
	for i in range(1, n - 1):
		if arr[i] - arr[i - 1] == 1:
			ans += 1
		elif arr[i] == arr[i - 1] and arr[i + 1] - arr[i] >= 1:
			arr[i] += 1
			ans += 1
		elif arr[i] - arr[i - 1] > 1:
			ans += 1
			arr[i] -= 1
		elif arr[i + 1] - arr[i] > 1:
			arr[i] += 1
			ans += 1
	ans += 1
	print(ans)


n = int(input())
a = 0
q = 0
m = [int(x) for x in input().split()]
m.sort()
for i in m:
	r = True
	if r & (i > 1):
		if i - 1 > a:
			q += 1
			a = i - 1
			r = False
	if r & (i > 0):
		if i > a:
			q += 1
			a = i
			r = False
	if r & (i > 0):
		if i + 1 > a:
			q += 1
			a = i + 1
print(q)


n = int(input())
arr = set()
a = [0] + sorted([int(x) for x in input().split()]) + [10 ** 6]
for i in range(1, n + 1):
	if a[i - 1] < a[i] - 1:
		a[i] -= 1
for i in range(n, 0, -1):
	if a[i] < a[i + 1] - 1:
		a[i] += 1
	arr.add(a[i])
print(len(arr))


input()
xs = sorted([int(x) for x in input().split()])
count = 0
low = 0
for x in xs:
	if x + 1 > low:
		count += 1
		low = max(low + 1, x - 1 if x - 1 > 0 else 1)
print(count)


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())
w = list(map(int, input().split()))
w.sort()
ma = 0
ans = 0
for i in range(n):
	if ma > w[i]:
		continue
	elif ma == w[i]:
		ma = w[i] + 1
		ans += 1
	elif ma + 1 == w[i]:
		ma = w[i]
		ans += 1
	else:
		ma = w[i] - 1
		ans += 1
print(ans)


n = int(input())
k = []
f = 0
count = 1
k = list(input().split())
for i in range(n):
	k[i] = int(k[i])
k.sort()
if int(k[0]) != 1:
	k[0] = int(k[0]) - 1
for i in range(1, n):
	if int(k[i]) == int(k[i - 1]) and int(k[i]) > f:
		k[i] = int(k[i]) + 1
		f = int(k[i - 1])
		count += 1
		continue
	elif int(k[i]) - int(k[i - 1]) > 1:
		count += 1
		k[i] = int(k[i]) - 1
		continue
	elif int(k[i]) - int(k[i - 1]) == 1:
		count += 1
		continue
	elif int(k[i]) < int(k[i - 1]):
		k[i] = int(k[i - 1])
		continue
print(count)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
C = Counter(A)
mx = max(A)
C2 = Counter()
for i in range(1, mx + 1):
	if i != 1 and C2[i - 1] == 0 and (C[i] > 0):
		C2[i - 1] += 1
		C[i] -= 1
	if C2[i] == 0 and C[i] > 0:
		C2[i] += 1
		C[i] -= 1
	C2[i + 1] = C[i]
	C[i] = 0
ans = 0
for v in C2.values():
	if v > 0:
		ans += 1
print(ans)


n = int(input())
b = list(map(int, input().split()))
d = set()
b.sort()
for i in range(n):
	if b[i] - 1 > 0 and b[i] - 1 not in d:
		d.add(b[i] - 1)
	elif b[i] not in d:
		d.add(b[i])
	elif b[i] + 1 not in d:
		d.add(b[i] + 1)
print(len(d))


n = int(input())
a = [int(item) for item in input().split()]
rank = [0] * 150010
rank[0] = 1
a.sort()
for item in a:
	if rank[item - 1] == 0:
		rank[item - 1] = 1
	elif rank[item] == 0:
		rank[item] = 1
	elif rank[item + 1] == 0:
		rank[item + 1] = 1
print(sum(rank[1:150005]))


n = int(input())
a = sorted(map(int, input().split()), reverse=True)
lst = 10 ** 18
ans = n
for x in a:
	if lst > x + 1:
		lst = x + 1
	elif lst > x:
		lst = x
	elif lst > x - 1 and x - 1 > 0:
		lst = x - 1
	else:
		ans -= 1
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
ub = 150002
cnt = 0
for x in a:
	if x + 1 < ub:
		ub = x + 1
		cnt += 1
	elif x < ub:
		ub = x
		cnt += 1
	elif x - 1 > 0 and x - 1 < ub:
		ub = x - 1
		cnt += 1
print(cnt)


n = int(input())
a = [0] * 150010
for x in map(int, input().split()):
	a[x] += 1
for i in range(2, 150001):
	if a[i] and a[i - 1] == 0:
		a[i - 1] = 1
		a[i] -= 1
for i in range(150000, 0, -1):
	if a[i] and a[i + 1] == 0:
		a[i + 1] = 1
		a[i] -= 1
for i in range(150002):
	if a[i] > 1:
		a[i] = 1
print(sum(a))


n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
b = defaultdict(int)
for i in a:
	b[i] += 1
c = set()
b = sorted(zip(b.keys(), b.values()))
for i in b:
	(p, q) = (i[0], i[1])
	if p not in c:
		if p == 1:
			t = q
			c.add(1)
			if t - 1 > 0:
				c.add(2)
		else:
			(t, r) = (q, 0)
			if p - 1 in c:
				c.add(p)
			else:
				c.add(p - 1)
				r = 1
			if r == 1 and t - 1 > 0:
				c.add(p)
			if r == 1 and t - 2 > 0:
				c.add(p + 1)
			if r == 0 and t - 1 > 0:
				c.add(p + 1)
	else:
		c.add(p + 1)
print(len(c))


def adding(cout, x, d):
	if x - 1 > 0:
		if d.get(x - 1) == None:
			d[x - 1] = 0
			cout -= 1
	if cout > 0:
		if d.get(x) == None:
			d[x] = 0
			cout -= 1
	if cout > 0:
		if d.get(x + 1) == None:
			d[x + 1] = 0
n = int(input())
lst = list(map(int, input().split()))
lst.sort()
(cout, d) = (1, {})
for i in range(1, n):
	x = lst[i - 1]
	if lst[i] != x:
		adding(cout, x, d)
		cout = 1
	else:
		cout += 1
x = lst[n - 1]
adding(cout, x, d)
print(len(d))


n = int(input())
ar = [int(j) for j in input().split()]
br = [0] * 200002
ar = sorted(ar)
for i in range(n):
	if ar[i] - 1 >= 1 and br[ar[i] - 1] == 0:
		br[ar[i] - 1] = 1
	elif br[ar[i]] == 0:
		br[ar[i]] = 1
	elif br[ar[i] + 1] == 0:
		br[ar[i] + 1] = 1
ma = max(ar) + 1
res = 0
for i in range(1, ma + 1):
	if br[i] == 1:
		res += 1
print(res)


n = int(input())
s = list(map(int, input().split()))
s.sort(reverse=True)
p = s[0] + 2
count = 0
for i in range(n):
	if s[i] + 1 < p:
		count += 1
		p = s[i] + 1
	elif s[i] < p:
		count += 1
		p = s[i]
	elif s[i] - 1 < p and s[i] - 1 != 0:
		count += 1
		p = s[i] - 1
print(count)


n = int(input())
a = list(map(int, input().split()))
isExist = []
for i in range(0, 150002):
	isExist.append(False)
a.sort()
isExist[0] = True
if a[0] > 1:
	a[0] -= 1
isExist[a[0]] = True
k = 1
for i in range(1, n):
	if a[i] - 1 != a[i - 1] and isExist[a[i] - 1] == False:
		a[i] -= 1
		isExist[a[i]] = True
		k += 1
	elif a[i] != a[i - 1] and isExist[a[i]] == False:
		isExist[a[i]] = True
		k += 1
	elif a[i] + 1 != a[i - 1] and isExist[a[i] + 1] == False:
		a[i] += 1
		isExist[a[i]] = True
		k += 1
print(k)


n = int(input())
l = list(map(int, input().split()))
a = [0] * 150002
l.sort(reverse=True)
for i in range(n):
	if a[l[i] + 1] == 0:
		a[l[i] + 1] = 1
	elif a[l[i]] == 0:
		a[l[i]] = 1
	elif a[l[i] - 1] == 0 and l[i] != 1:
		a[l[i] - 1] = 1
	else:
		continue
ans = 0
for i in range(len(a)):
	if a[i] > 0:
		ans += 1
print(ans)


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)


import math
import sys
n = int(input())
a = list(map(int, input().split()))
d = [0] * 150001
for i in range(n):
	d[a[i] - 1] += 1
if d[0] >= 2:
	d[1] += 1
	d[0] -= 1
for i in range(1, len(d)):
	if d[i] > 0:
		if d[i] >= 3:
			d[i - 1] += 1
			d[i + 1] += 1
			d[i] -= 2
		elif d[i] == 2:
			if d[i - 1] == 0:
				d[i - 1] += 1
				d[i] -= 1
			else:
				d[i] -= 1
				d[i + 1] += 1
		elif d[i - 1] == 0:
			d[i - 1] = 1
			d[i] = 0
print(150001 - d.count(0))


n = int(input())
weights = sorted((int(i) for i in input().split()))
possibles = set()
for i in weights:
	if i - 1 not in possibles and i - 1 > 0:
		possibles.add(i - 1)
	elif i not in possibles:
		possibles.add(i)
	else:
		possibles.add(i + 1)
print(len(possibles))


from collections import Counter, defaultdict
import math

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

def getvalue():
	return int(input())

def getstring():
	return input()
n = getvalue()
l = getlist()
l.sort()
tot = 0
li = [0] * 150003
for i in l:
	li[i] += 1
for i in range(1, 150001):
	if li[i]:
		if i == 1 and li[i] > 1:
			tot += 1
			if li[i] > 1:
				li[i + 1] += 1
				li[i] -= 1
		elif i > 1 and li[i] == 1:
			tot += 1
			if li[i - 1] == 0:
				li[i] -= 1
				li[i - 1] += 1
		elif i > 1 and li[i] == 2:
			tot += 1
			if li[i - 1] == 0:
				li[i] -= 1
				li[i - 1] += 1
				tot += 1
			else:
				li[i] -= 1
				li[i + 1] += 1
		elif i > 1 and li[i] >= 3:
			tot += 1
			if li[i - 1] == 0:
				li[i] -= 1
				li[i - 1] += 1
				tot += 1
			li[i] -= 1
			li[i + 1] += 1
print(sum((1 if li[i] else 0 for i in range(1, 150002))))


import sys
input = sys.stdin.readline
from math import *
n = int(input())
a = [int(x) for x in input().split()]
d = {}
a.sort()
c = 0
for i in range(n):
	if a[i] - 1 > 0 and a[i] - 1 not in d:
		c += 1
		d[a[i] - 1] = 1
	elif a[i] not in d:
		d[a[i]] = 1
		c += 1
	elif a[i] + 1 not in d:
		d[a[i] + 1] = 1
		c += 1
print(c)


n = int(input())
a = [*map(int, input().split())]
from collections import Counter
c = Counter(a)
ans = set()
for i in sorted(c.keys()):
	if i != 1 and i - 1 not in ans:
		ans.add(i - 1)
		c[i] -= 1
	if c[i] and i not in ans:
		ans.add(i)
		c[i] -= 1
	if c[i] and i + 1 not in ans:
		ans.add(i + 1)
print(len(ans))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import heapq
from collections import Counter
s = int(input())
arr = list(map(int, input().split()))
arr.sort()
c = Counter(arr)
ans = 0
ls = [0] * 150002
for i in c:
	if i - 1 > 0 and ls[i - 1] == 0:
		ans += 1
		ls[i - 1] = 1
		c[i] -= 1
	if c[i] > 0 and ls[i] == 0:
		ls[i] = 1
		ans += 1
		c[i] -= 1
	if c[i] > 0 and ls[i + 1] == 0:
		ans += 1
		ls[i + 1] = 1
		c[i] -= 1
print(ans)


from sys import stdin, exit
from typing import List, Tuple, Dict
stdin.readline()
boxers = [int(v) for v in stdin.readline().rstrip().split()]
boxers.sort()
if boxers[0] != 1:
	boxers[0] -= 1
for i in range(1, len(boxers)):
	if boxers[i] - boxers[i - 1] >= 2:
		boxers[i] -= 1
	elif boxers[i] - boxers[i - 1] == 0:
		boxers[i] += 1
	elif boxers[i] - boxers[i - 1] < 0:
		boxers[i] = boxers[i - 1]
print(len(set(boxers)))


n = int(input())
boxers_weight = []
data = input().split(' ')
for i in data:
	boxers_weight.append(int(i))
boxers_weight.sort(reverse=True)
inf = float('inf')
res = 0
for i in boxers_weight:
	if i + 1 < inf:
		res += 1
		inf = i + 1
	elif i < inf:
		res += 1
		inf = i
	elif i - 1 < inf and i - 1 > 0:
		res += 1
		inf = i - 1
print(res)