Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Kerim is an environment-friendly guy. Today, he accepted Samir's challenge of planting 20 million trees by 2020. Currently, there are $N$ trees (numbered $1$ through $N$) planted at distinct positions on a line; for each valid $i$, the position of the $i$-th tree is $A_{i}$.

A set of trees is *beautiful* if for each tree in this set (let's denote its position by $x$), there is a tree at the position $x-1$ and/or a tree at the position $x+1$.

Kerim's task is to plant some (possibly zero) trees in such a way that the resulting set of all planted trees (the initial $N$ trees and those planted by Kerim) is beautiful. It is only allowed to plant trees at integer (possibly negative) positions. Find the minimum number of trees he needs to plant in order to achieve that.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains $N$ space-separated integers $A_{1}, A_{2}, \ldots, A_{N}$.

------  Output ------
For each test case, print a single line containing one integer ― the minimum number of trees Kerim needs to plant.

------  Constraints  ------
$1 ≤ T ≤ 1,000$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i} ≤ 10^{9}$ for each valid $i$
$A_{1}, A_{2}, \ldots, A_{N}$ are pairwise distinct
the sum of $N$ over all test cases does not exceed $10^{6}$

------  Subtasks ------
Subtask #1 (50 points):
$N ≤ 1,000$
$A_{i} ≤ 2,000$ for each valid $i$
the sum of $N$ over all test cases does not exceed $10^{4}$

Subtask #2 (50 points): original constraints

----- Sample Input 1 ------ 
1

3

2 7 4
----- Sample Output 1 ------ 
2
----- explanation 1 ------ 
Example case 1: Kerim should plant trees at the positions $3$ and $6$ to make the grid beautiful, so the answer is $2$.

Difficulty: MEDIUM_HARD
Tags: Sorting
Skill types: Sorting

Starter code:

Solutions:
for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = {}
	for i in a:
		d[i] = True
	c = 0
	for i in a:
		try:
			d[i - 1] == True
		except:
			try:
				d[i + 1] == True
			except:
				d[i + 1] = True
				c += 1
	print(c)


for _ in range(int(input())):
	n = int(input())
	nli = list(map(int, input().split()))
	nli.sort()
	nli.insert(0, -5)
	nli.append(-5)
	cnt = 0
	for i in range(1, n + 1):
		if nli[i] + 1 != nli[i + 1] and nli[i] != nli[i - 1] + 1:
			cnt += 1
			nli[i] += 1
	print(cnt)


import math
for i in range(int(input())):
	n = int(input())
	A = [int(k) for k in input().split()]
	A.sort()
	if n == 1:
		print(1)
	else:
		k = 0
		c = 0
		for k in range(n):
			if k == 0:
				if A[k + 1] - A[k] > 1:
					A[k] += 1
					c += 1
			elif k == n - 1:
				if A[k] - A[k - 1] > 1:
					c += 1
			elif A[k] - A[k - 1] > 1 and A[k + 1] - A[k] > 1:
				c += 1
				A[k] += 1
		print(c)


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	prev = None
	c = 0
	for i in range(n - 1):
		if (prev is None or prev != arr[i] - 1) and arr[i + 1] - 1 != arr[i]:
			c += 1
			prev = arr[i] + 1
		else:
			prev = arr[i]
	if prev != arr[n - 1] - 1:
		c += 1
	print(c)


t = int(input())
for tc in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	arr.sort()
	arr += [-1]
	d = set()
	res = 0
	if arr[0] + 1 != arr[1]:
		res += 1
		d.add(arr[0] + 1)
	for i in range(1, n):
		if arr[i] - 1 != arr[i - 1] and arr[i] + 1 != arr[i + 1] and (arr[i] - 1 not in d) and (arr[i] + 1 not in d):
			res += 1
			d.add(arr[i] + 1)
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	j = 0
	ct = 0
	prev = -2
	while j < n:
		if j == n - 1:
			if lis[j] - prev == 1:
				break
			else:
				ct += 1
				break
		if lis[j] - prev == 1:
			prev = lis[j]
			j += 1
			continue
		if lis[j + 1] - lis[j] == 1:
			prev = lis[j]
			j += 1
			continue
		if lis[j + 1] - lis[j] == 2:
			prev = lis[j] + 1
			j += 1
			ct += 1
			continue
		elif lis[j + 1] - lis[j] > 2:
			prev = lis[j] + 1
			ct += 1
			j += 1
			continue
	print(ct)


T = int(input())
for i in range(T):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	c = 0
	a.sort()
	i = 0
	while i < len(a):
		if i < len(a) - 1 and a[i + 1] == a[i] + 1:
			i += 1
			continue
		if i > 0 and a[i - 1] == a[i] - 1:
			i += 1
			continue
		a.insert(i + 1, a[i] + 1)
		i += 1
		c += 1
	print(c)


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))[:n]
	c = 0
	a.sort()
	i = 0
	while i < len(a):
		if i < len(a) - 1 and a[i + 1] == a[i] + 1:
			i += 1
			continue
		if i > 0 and a[i - 1] == a[i] - 1:
			i += 1
			continue
		a.insert(i + 1, a[i] + 1)
		i += 1
		c += 1
	print(c)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	j = 0
	count = 0
	while j < n:
		if j < n - 1 and a[j + 1] - a[j] == 1:
			j += 2
		elif j > 1 and a[j] - a[j - 1] == 1:
			j += 1
		elif j < n - 1 and a[j + 1] - a[j] == 2:
			count += 1
			j += 2
		else:
			count += 1
			j += 1
	print(count)


t = int(input())
for i in range(t):
	count = 0
	j = 0
	n = int(input())
	l = sorted(list(map(int, input().split())))
	while j < n:
		if j < n - 1 and l[j + 1] - l[j] == 1:
			j += 2
		elif j > 1 and l[j] - l[j - 1] == 1:
			j += 1
		elif j < n - 1 and l[j + 1] - l[j] == 2:
			count += 1
			j += 2
		else:
			count += 1
			j += 1
	print(count)


T = int(input())
ans = []
for _ in range(T):
	N = int(input())
	A = [int(i) for i in input().split()]
	A.sort()
	count = 0
	Trees = {}
	for i in range(N):
		Trees[A[i]] = True
	for i in range(N):
		Flag = False
		if A[i] > A[0]:
			if A[i] - 1 in Trees:
				Flag = True
		if A[i] < A[-1]:
			if A[i] + 1 in Trees:
				Flag = True
		if not Flag:
			if A[i] < A[-1]:
				Trees[A[i] + 1] = True
				count += 1
			else:
				Trees[A[i] - 1] = True
				count += 1
	ans.append(count)
for i in ans:
	print(i)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	i = 0
	count = 0
	while i < len(li):
		if i < len(li) - 1 and li[i + 1] == li[i] + 1:
			i += 1
			continue
		if i > 0 and li[i - 1] == li[i] - 1:
			i += 1
			continue
		else:
			li.insert(i + 1, li[i] + 1)
			count += 1
			i += 1
	print(count)


import math
test = int(input())
for _ in range(test):
	n = int(input())
	a = [int(x) for x in input().split()]
	if n == 1:
		print(1)
		continue
	ans = 0
	a.sort()
	if a[0] + 1 != a[1]:
		a[0] += 1
		ans += 1
	i = 1
	while i < n - 1:
		if a[i - 1] == a[i] - 1:
			i += 1
		elif a[i] + 1 == a[i + 1]:
			i += 1
		else:
			ans += 1
			a[i] += 1
			i += 1
	if a[-2] != a[-1] - 1:
		ans += 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	ans = 0
	added = -2
	for i in range(n):
		if l[i - 1] != l[i] - 1 and l[(i + 1) % n] != l[i] + 1 and (added != l[i] - 1):
			added = l[i] + 1
			ans += 1
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	l = [-9] + list(map(int, input().split())) + [9999999999]
	l.sort()
	i = 1
	c = 0
	m = [9999999999]
	for i in range(1, n + 1):
		if l[i] - l[i - 1] != 1 and l[i] - m[-1] != 1 and (l[i + 1] - l[i] != 1):
			m.append(l[i] + 1)
			c += 1
	print(c)
	t -= 1


def plant(tree_list, n):
	tree_list.sort()
	trees = set(tree_list)
	c = 0
	for i in range(n):
		if tree_list[i] - 1 in trees or tree_list[i] + 1 in trees:
			pass
		else:
			c += 1
			trees.add(tree_list[i] + 1)
	return c
T = int(input())
for case in range(T):
	tree_count = int(input())
	InT = list(map(int, input().split()))
	print(plant(InT, tree_count))


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	a = set(x)
	d = 0
	for i in range(n):
		if x[i] - 1 in a or x[i] + 1 in a:
			continue
		else:
			a.add(x[i] + 1)
			d += 1
	print(d)


t = int(input())
for tst in range(t):
	n = input()
	l = list(map(int, input().split()))
	l.sort()
	d = {}
	for i in l:
		d[i] = 1
	count = 0
	for i in range(len(l)):
		if l[i] + 1 in d or l[i] - 1 in d:
			continue
		else:
			d[l[i] + 1] = 1
			count += 1
	print(count)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	D = {}
	for j in range(n):
		D[arr[j]] = 1
		if arr[j] - 1 not in D:
			D[arr[j] + 1] = 1
	print(len(D) - n)


from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(10000000)

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

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

def o():
	return int(input())

def r(x):
	if type(x) == int:
		return range(x)
	else:
		return range(len(x))

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
MOD = 1000000007
MAX = float('inf')
MIN = -float('inf')
p = input
for _ in r(o()):
	n = o()
	l = sorted(op())
	c = 0
	i = 0
	f = 0
	while i < len(l) - 1:
		x = l[i + 1] - l[i]
		if f == 1:
			if x == 1:
				f = 1
			else:
				f = 0
			i += 1
			continue
		if x >= 2:
			c += 1
		if x in [1, 2]:
			f = 1
		i += 1
	if f == 0:
		c += 1
	print(c)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	count = 0
	s.sort()
	l = dict()
	for i in s:
		l[i] = 1
	for i in s:
		if i - 1 not in l and i + 1 not in l:
			count += 1
			l[i + 1] = 1
	print(count)


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	p.sort()
	ans = 0
	last = -1
	for x in p:
		if x == last:
			ans -= 1
		elif x == last + 1:
			last = x
		else:
			last = x + 1
			ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = []
	count = 0
	d = {}
	l = list(map(int, input().split()))
	l.sort()
	for i in l:
		d[i] = 0
	for i in l:
		b = i - 1
		a = i + 1
		if a not in d and b not in d:
			d[a] = 0
			count += 1
	print(count)


for _ in range(int(input())):
	(n, lis, count) = (int(input()), list(map(int, input().split())), 0)
	(lis.append(-1), lis.sort(), lis.append(-1))
	for i in range(1, len(lis) - 1):
		if lis[i + 1] == lis[i] + 1 or lis[i - 1] == lis[i] - 1:
			x = 0
		else:
			(lis[i], count) = (lis[i] + 1, count + 1)
	print(count)


t = input()
for _ in range(int(t)):
	n = int(input())
	a = input().split()
	present = dict()
	for i in range(n):
		a[i] = int(a[i])
		present.__setitem__(a[i], 1)
	a.sort()
	ct = 0
	for i in range(n):
		if a[i] - 1 in present.keys():
			continue
		if a[i] + 1 in present.keys():
			continue
		present.__setitem__(a[i] + 1, 1)
		ct += 1
	print(ct)


def solve(n, a):
	cnt = 0
	last = -1
	for a_i in sorted(a):
		if a_i == last:
			cnt -= 1
		elif a_i == last + 1:
			last = a_i
		else:
			cnt += 1
			last = a_i + 1
	return cnt

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		print(solve(n, a))
main()


def numoftree(arr, n):
	di = dict()
	di[arr[0]] = 1
	count = 0
	for i in range(n):
		di[arr[i]] = 1
	for i in range(n):
		if arr[i] - 1 not in di and arr[i] + 1 not in di:
			di[arr[i] + 1] = 1
			count += 1
	return count
t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	li.sort()
	print(numoftree(li, n))


for ii in range(int(input())):
	n = int(input())
	l = [-1] + sorted(list(map(int, input().split()))) + [-1]
	s = 0
	for i in range(1, n + 1):
		if l[i] != l[i + 1] - 1 and l[i] != l[i - 1] + 1:
			s += 1
			l[i] += 1
	print(s)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	arr.insert(0, -1)
	arr.append(-1)
	ans = 0
	for i in range(1, n + 1):
		if arr[i] + 1 != arr[i + 1] and arr[i] - 1 != arr[i - 1]:
			ans += 1
			arr[i] += 1
	print(ans)


li2 = [1, 4, 8, 10, 2]

def fun(li):
	li.sort()
	c = 0
	temp = 100000000000
	if len(li) > 2:
		if li[0] + 1 != li[1]:
			c = c + 1
			temp = li[0] + 1
		for i in range(1, len(li) - 1):
			if li[i] + 1 != li[i + 1] and li[i] - 1 != li[i - 1] and (li[i] - 1 != temp):
				c = c + 1
				temp = li[i] + 1
		if li[-1] - 1 != temp and li[-1] - 1 != li[len(li) - 2]:
			c = c + 1
	if len(li) == 2:
		if li[0] + 1 == li[1]:
			return c
		else:
			temp = li[0] + 1
			if li[1] - 1 == temp:
				return 1
			else:
				return 2
	if len(li) == 1:
		return 1
	return c
t = int(input())
for i in range(0, t):
	s = int(input())
	li = list(map(int, input().strip().split()))
	print(fun(li))


for T in range(int(input())):
	N = int(input())
	tree = list(map(int, input().split()))
	tree.sort()
	totPlanted = 0
	lastPlanted = -1
	i = 0
	while i < N:
		t = tree[i]
		if i > 0 and tree[i - 1] == t - 1:
			i += 1
		elif i < N - 1 and tree[i + 1] == t + 1:
			i += 1
		elif lastPlanted == t - 1:
			i += 1
		else:
			totPlanted += 1
			lastPlanted = t + 1
			i += 1
	print(totPlanted)


class dd(dict):

	def __missing__(self, k):
		self[k] = 0
		return 0
for _ in range(int(input())):
	d = dd()
	n = int(input())
	__ = [d[int(__0)] for __0 in input().split()]
	del __
	ans = 0
	d1 = dict(d)
	for k in sorted(d.keys()):
		if k + 1 in d1 or k - 1 in d1:
			continue
		d1[k + 1] = 0
		ans += 1
	print(ans)


from collections import defaultdict as dd
for _ in range(int(input())):
	d = dd(lambda : 0)
	n = int(input())
	for __ in input().split():
		d[int(__)] = 0
	ans = 0
	d1 = dict(d)
	for k in sorted(d.keys()):
		if k + 1 in d1 or k - 1 in d1:
			continue
		d1[k + 1] = 0
		ans += 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	count = 0
	a.sort()
	if n == 1:
		print(1)
		continue
	for i in range(len(a)):
		if i == 0:
			if a[i + 1] == a[i] + 1:
				y = a[i]
				pass
			else:
				y = a[i] + 1
				count += 1
			continue
		if i == len(a) - 1:
			if y == a[i] - 1:
				pass
			else:
				count += 1
			continue
		if a[i + 1] == a[i] + 1 or y == a[i] - 1:
			y = a[i]
			pass
		else:
			y = a[i] + 1
			count += 1
	print(count)


from collections import defaultdict
from heapq import *
import itertools, math

def parse_integer_list():
	return [int(x) for x in input().split()]

def handle_input(A, N):
	A.sort()
	N = len(A)
	if N == 1:
		return 1
	cnt = 0
	i = 0
	while i < N:
		if i == 0:
			if A[1] > A[0] + 1:
				cnt += 1
			if A[1] == A[0] + 2:
				i += 1
			i += 1
			continue
		if i == N - 1:
			if A[N - 1] > A[-2] + 1:
				cnt += 1
			i += 1
			continue
		if A[i - 1] == A[i] - 1 or A[i + 1] == A[i] + 1:
			i += 1
			continue
		cnt += 1
		if A[i + 1] == A[i] + 2:
			i += 1
		i += 1
	return cnt
T = int(input())
for i in range(T):
	N = int(input())
	A = parse_integer_list()
	print(handle_input(A, N))


t11 = int(input())
while t11:
	t11 -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	if n == 1:
		print(1)
		continue
	t = 0
	prev = 0
	while i < n:
		if i == 0:
			if a[1] == a[0] + 1:
				pass
			else:
				prev = a[i] + 1
				t += 1
		elif i == n - 1:
			if a[i - 1] + 1 == a[i] or abs(prev - a[i]) == 1:
				pass
			else:
				t += 1
		elif a[i - 1] + 1 == a[i] or a[i + 1] == a[i] + 1 or abs(prev - a[i]) == 1:
			pass
		else:
			prev = a[i] + 1
			t += 1
		i += 1
	print(t)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	dic = {}
	for x in arr:
		dic[x] = 1
	ans = 0
	for i in range(len(arr)):
		if arr[i] - 1 in dic or arr[i] + 1 in dic:
			continue
		else:
			dic[arr[i] + 1] = True
			ans += 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	from collections import defaultdict
	d = defaultdict(int)
	for x in A:
		d[x] = 1
	A = sorted(A)
	answer = 0
	for x in A:
		if d[x + 1] == 1 or d[x - 1] == 1:
			continue
		if d[x + 1] == 0 and d[x - 1] == 0 and (d[x + 2] == 0) and (d[x - 2] == 0):
			d[x + 1] = 1
			answer += 1
			continue
		if d[x + 1] == 0 and d[x + 2] == 1:
			answer += 1
			d[x + 1] = 1
			continue
		if d[x - 1] == 0 and d[x - 2] == 1:
			answer += 1
			d[x - 1] = 1
			continue
	print(answer)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	l.sort()
	count = 0
	last = -100
	for i in range(n - 1):
		if last + 1 < l[i] and l[i] + 1 < l[i + 1]:
			count += 1
			last = l[i] + 1
		else:
			last = l[i]
	if last + 1 < l[n - 1]:
		count += 1
	print(count)


for _ in range(int(input())):
	N = int(input())
	A = [int(x) for x in input().split()]
	A.sort()
	A.append(A[N - 1] + 2)
	ans = 0
	i = 0
	last = A[0] - 2
	while i < N:
		if last + 1 == A[i]:
			last = A[i]
			i += 1
		elif A[i] + 1 == A[i + 1]:
			last = A[i + 1]
			i += 2
		elif A[i] + 2 == A[i + 1]:
			last = A[i + 1]
			ans += 1
			i += 2
		else:
			last = A[i] + 1
			ans += 1
			i += 1
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	tree_dict = set(a)
	to_plant = 0
	for i in range(n):
		(prev, nex) = (a[i] - 1, a[i] + 1)
		if prev not in tree_dict and nex not in tree_dict:
			to_plant += 1
			tree_dict.add(nex)
	print(to_plant)


def main():
	n = int(input())
	l = [int(j) for j in input().split()]
	ans = 0
	i = 0
	l.sort()
	if n == 1:
		print(1)
		return
	l = [-1] + l + [-1]
	for i in range(1, n + 1):
		if l[i] - l[i - 1] != 1 and l[i + 1] - l[i] != 1:
			ans += 1
			l[i] += 1
	print(ans)
	return
for t in range(int(input())):
	main()


t = int(input())
for i in range(t):
	n = int(input())
	inp = list(map(int, input().split()))
	inp.sort()
	bod = []
	count = 0
	if len(inp) == 1:
		print(1)
	else:
		for k in range(1, len(inp) - 1):
			if min(abs(inp[k] - inp[k - 1]), abs(inp[k] - inp[k + 1])) > 1:
				bod.append(inp[k])
		if inp[1] - inp[0] > 1:
			bod = [inp[0]] + bod
		if inp[-1] - inp[-2] > 1:
			bod.append(inp[-1])
		k = 0
		if len(bod) == 0:
			print(0)
		elif len(bod) == 1:
			print(1)
		else:
			while k < len(bod) - 1:
				if bod[k + 1] - bod[k] == 2:
					count += 1
					k += 2
					continue
				else:
					count += 1
					k += 1
			if k == len(bod) - 1:
				count += 1
			print(count)


for _ in range(int(input())):
	n = int(input())
	l = [int(j) for j in input().split()]
	l.sort()
	c = 0
	d = dict()
	s = set(l)
	for i in range(n - 1):
		if l[i] + 1 not in s and l[i] - 1 not in s:
			c += 1
			s.add(l[i] + 1)
	if l[-1] - 1 not in s:
		c += 1
	print(c)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	l.insert(0, 0)
	l1 = []
	l2 = []
	for i in range(1, len(l)):
		if l[i - 1] == 0 and len(l) > 2 and (l[i + 1] != l[i] + 1):
			l1.append(l[i] + 1)
			l2.append(1)
		elif l[i - 1] == 0 and len(l) <= 2:
			l1.append(l[i] + 1)
			l2.append(1)
		elif l[i - 1] + 1 != l[i] and len(l1) != 0 and (l[i] != l1[len(l1) - 1] + 1):
			if i != len(l) - 1 and l[i + 1] != l[i] + 1:
				l1.append(l[i] + 1)
				l2.append(1)
			elif i == len(l) - 1:
				l1.append(l[i] - 1)
				l2.append(1)
			else:
				l1.append(0)
				l2.append(0)
		else:
			l1.append(0)
			l2.append(0)
	print(sum(l2))


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


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	count = 0
	i = 0
	b = []
	while i < n - 1:
		if a[i + 1] == a[i] + 1:
			i += 2
			continue
		elif i != 0 and a[i - 1] + 1 != a[i]:
			b.append(a[i])
		elif i == 0:
			b.append(a[i])
		i += 1
	if i == n - 1 and a[n - 1] != a[n - 2] + 1:
		b.append(a[n - 1])
	i = 0
	while i < len(b) - 1:
		if b[i + 1] - b[i] == 2:
			i += 1
		count += 1
		i += 1
	if i == len(b) - 1:
		count += 1
	print(count)


test = int(input())
while test > 0:
	test -= 1
	sum = 0
	n = int(input())
	ls = list(map(int, input().split()))
	lss = set(ls)
	ls.sort()
	for i in ls:
		if i + 1 in lss or i - 1 in lss:
			pass
		else:
			lss.add(i + 1)
			sum += 1
	print(sum)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().strip().split(' ')))
	li.sort()
	m = set()
	for i in li:
		m.add(i)
	i = 0
	c = 0
	while i < n:
		if i < n - 1:
			if li[i + 1] - li[i] == 1:
				i += 2
			elif li[i] - 1 in m:
				i += 1
			elif li[i + 1] - li[i] == 2:
				c += 1
				m.add(li[i] + 1)
				i += 2
			else:
				c += 1
				m.add(li[i] - 1)
				i += 1
		elif li[i] - 1 in m:
			i += 1
		else:
			i += 1
			c += 1
	print(c)


for _ in range(int(input())):
	n = int(input())
	A = [int(i) for i in input().split()]
	A.sort()
	has = {}
	for i in A:
		has[i] = 1
	c = 0
	for i in range(len(A)):
		if A[i] + 1 in has or A[i] - 1 in has:
			continue
		else:
			has[A[i] + 1] = 1
			c += 1
	print(c)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	ar.sort()
	arr = [ar[0], ar[0] + 1]
	for i in ar[1:]:
		if i != arr[-1]:
			arr.append(i)
		if arr[-2] == arr[-1] - 1:
			pass
		else:
			arr.append(i + 1)
	count = len(arr) - n
	print(count)


try:
	t = int(input())
	for _ in range(t):
		n = int(input())
		l = list(map(int, input().split()))
		l.sort()
		count = 0
		i = 0
		while i < n:
			if i + 1 == n:
				if l[i] - 1 == l[i - 1]:
					pass
				else:
					count += 1
				i += 1
			elif i == 0:
				if l[i] + 1 == l[i + 1]:
					i += 2
				elif l[i] + 2 == l[i + 1]:
					count += 1
					i += 2
				else:
					count += 1
					i += 1
			elif l[i] + 1 == l[i + 1]:
				i += 2
			elif l[i] - 1 == l[i - 1]:
				i += 1
			elif l[i] + 2 == l[i + 1]:
				count += 1
				i += 2
			elif l[i] - 2 == l[i - 1]:
				count += 1
				i += 1
			else:
				count += 1
				i += 1
		print(count)
except:
	pass


from sys import stdin
from collections import defaultdict
t = int(stdin.readline())
while t:
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	if n == 1:
		print(1)
	else:
		d = defaultdict(int)
		a.sort()
		(ans, diff) = (0, a[1] - a[0])
		temp = []
		if diff >= 2:
			ans = 1
			temp.append(a[0])
			temp.append(a[0] + 1)
		else:
			temp.append(a[0])
		for i in range(1, n - 1):
			if temp[-1] == a[i] - 1:
				temp.append(a[i])
				continue
			if a[i + 1] == a[i] + 1:
				temp.append(a[i])
				continue
			else:
				temp.append(a[i])
				temp.append(a[i] + 1)
				ans += 1
		if a[-1] - 1 != temp[-1]:
			ans += 1
		print(ans)
	t -= 1


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	c = 0
	if n == 1:
		print(1)
		continue
	for i in range(n):
		if i == 0 and a[i + 1] != a[i] + 1:
			a[i] = a[i] + 1
			c += 1
			continue
		if i == n - 1 and a[i - 1] != a[i] - 1:
			c += 1
		elif a[i - 1] == a[i] - 1:
			continue
		elif a[i] != a[i + 1] - 1:
			a[i] = a[i] + 1
			c += 1
	print(c)


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	has = {}
	for i in arr:
		has[i] = 1
	co = 0
	for i in range(n):
		try:
			has[arr[i] - 1]
		except:
			try:
				has[arr[i] + 1]
			except:
				has[arr[i] + 1] = 1
				co += 1
	print(co)


for _ in range(int(input())):
	n = int(input())
	l1 = sorted(list(map(int, input().split())))
	s = set(l1)
	c = 0
	for i in range(n):
		if l1[i] + 1 not in s and l1[i] - 1 not in s:
			s.add(l1[i] + 1)
			c += 1
	print(c)


from sys import stdin, stdout

def partition(arr, low, high):
	i = low - 1
	pivot = arr[high]
	for j in range(low, high):
		if arr[j] < pivot:
			i = i + 1
			(arr[i], arr[j]) = (arr[j], arr[i])
	(arr[i + 1], arr[high]) = (arr[high], arr[i + 1])
	return i + 1

def quickSort(arr, low, high):
	if low < high:
		pi = partition(arr, low, high)
		quickSort(arr, low, pi - 1)
		quickSort(arr, pi + 1, high)
for j in range(int(stdin.readline())):
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split()))
	quickSort(l, 0, n - 1)
	count = 0
	f = 0
	i = 0
	if n == 1:
		print(1)
		continue
	while i < n:
		if i == n - 1:
			a = l[i - 1]
			b = l[i]
			if b - a > 2:
				count += 1
				i += 1
				f = 0
			elif b - a == 2:
				count += 1
				i += 1
			else:
				i += 1
			continue
		if f == 0:
			b = l[i]
			c = l[i + 1]
			if c - b > 2:
				count += 1
				f = 0
				i += 1
				continue
			elif c - b == 2:
				count += 1
				f = 1
				i += 2
			else:
				i += 2
				f = 1
		else:
			a = l[i - 1]
			b = l[i]
			c = l[i + 1]
			if b - a == 1:
				f = 1
				i += 1
				continue
			elif c - b > 2:
				count += 1
				f = 0
				i += 1
				continue
			elif c - b == 2:
				count += 1
				f = 1
				i += 2
			elif c - b == 1:
				i += 2
				f = 1
	print(count)


for ii in range(int(input())):
	b = int(input())
	l = list(map(int, input().split()))
	l.sort()
	s = {}
	for i in l:
		s[i] = 0
	for i in range(b):
		up = l[i] + 1
		lw = l[i] - 1
		if up not in s and lw not in s:
			s[up] = 0
		else:
			continue
	print(len(s) - b)


te = int(input())
while te > 0:
	te -= 1
	n = int(input())
	trees = list(map(int, input().split()))
	trees.sort()
	ans = 0
	if n == 1:
		ans = 1
	else:
		if trees[1] - 1 != trees[0]:
			ans += 1
			trees[0] += 1
		i = 1
		while i < n - 1:
			if trees[i] - 1 != trees[i - 1] and trees[i + 1] - 1 != trees[i]:
				ans += 1
				trees[i] += 1
			i += 1
		if trees[n - 1] - trees[n - 2] != 1:
			ans += 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	alone = []
	if len(l) > 1 and l[1] - l[0] != 1:
		alone.append(l[0])
	for i in range(1, n - 1):
		if l[i + 1] - l[i] != 1 and l[i] - l[i - 1] != 1:
			alone.append(l[i])
	if l[n - 1] - l[n - 2] != 1:
		alone.append(l[n - 1])
	result = 0
	i = 0
	while i < len(alone) - 1:
		if alone[i + 1] - alone[i] == 2:
			i += 1
		result += 1
		i += 1
	if i == len(alone) - 1:
		result += 1
	print(result)


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


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = 0
	if n == 1:
		print(1)
		continue
	a.sort()
	for i in range(n):
		if i == 0:
			if a[i + 1] != a[i] + 1:
				cnt += 1
				a[i] = a[i] + 1
		elif i == n - 1:
			if a[i] - 1 != a[i - 1]:
				cnt += 1
		elif a[i] - 1 != a[i - 1] and a[i] + 1 != a[i + 1]:
			cnt += 1
			a[i] = a[i] + 1
	print(cnt)


t = int(input())
for q in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 0
	l = set(a)
	for i in range(n):
		if i == n - 1 and a[i] - 1 not in l:
			ans += 1
			l.add(a[i] - 1)
		if a[i] - 1 not in l and a[i] + 1 not in l:
			ans += 1
			l.add(a[i] + 1)
	print(ans)


def solve():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = [int(i) for i in input().split()]
		a = sorted(a)
		i = 0
		s = None
		if n > 1:
			c = 0
			while i < n:
				if i != n - 1:
					if i == 0:
						if a[i + 1] != a[i] + 1:
							c += 1
							s = a[i] + 1
						else:
							s = a[i]
					elif a[i + 1] != a[i] + 1 and s != a[i] - 1:
						c += 1
						s = a[i] + 1
					else:
						s = a[i]
				elif s != a[i] - 1:
					c += 1
				i += 1
			print(c)
		else:
			print(1)
solve()