Priyanka works for an international toy company that ships by container.  Her task is to the determine the lowest cost way to combine her orders for shipping.  She has a list of item weights.  The shipping company has a requirement that all items loaded in a container must weigh less than or equal to 4 units plus the weight of the minimum weight item.  All items meeting that requirement will be shipped in one container.

What is the smallest number of containers that can be contracted to ship the items based on the given list of weights?

For example, there are items with weights $w=[1,2,3,4,5,10,11,12,13]$.  This can be broken into two containers: $[1,2,3,4,5]$ and $[10,11,12,13]$.  Each container will contain items weighing within $\begin{array}{c}4\end{array}$ units of the minimum weight item.  

Function Description  

Complete the toys function in the editor below.  It should return the minimum number of containers required to ship.  

toys has the following parameter(s):  

w: an array of integers that represent the weights of each order to ship  

Input Format

The first line contains an integer $n$, the number of orders to ship. 

The next line contains $n$ space-separated integers, $w[1],w[2],\ldots,w[n]$,  representing the orders in a weight array.

Constraints

$1\leq n\leq10^5$ 

$0\leq w[i]\leq10^4,where\ i\in[1,n]$   

Output Format

Return the integer value of the number of containers Priyanka must contract to ship all of the toys. 

Sample Input
8
1 2 3 21 7 12 14 21

Sample Output
4

Explanation

The first container holds items weighing $\mbox{I}$, $2$ and $3$. (weights in range $1\ldots5$) 

The second container holds the items weighing $21$ units. ($21\ldots25$) 

The third container holds the item weighing $7$ units.  ($7...11$) 

The fourth container holds the items weighing $12$ and $\mathbf{14}$ units. ($12...14$)  

$\begin{array}{c}4\end{array}$ containers are required.

Difficulty: EASY
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import sys
N = int(sys.stdin.readline())
W = sorted(map(int, sys.stdin.readline().split()))
cost = 0
last_chosen = -5
for w in W:
	if w > last_chosen + 4:
		cost += 1
		last_chosen = w
print(cost)


def min_units(n, weights):
	sorted_weights = sorted(weights)
	num_bought = 1
	last_bought = sorted_weights[0]
	for w in sorted_weights[1:]:
		if w - last_bought > 4:
			last_bought = w
			num_bought += 1
	return num_bought

def main():
	n = int(input())
	weights = list(map(int, input().split()))
	print(min_units(n, weights))
main()


input()
toys = sorted(map(int, input().split()))
s = 1
last = toys[0]
for t in toys:
	if t > last + 4:
		s += 1
		last = t
print(s)


N = int(input())
A = list(map(int, input().split()))
A.sort()
num = 0
deja = -1
for a in A:
	if a > deja:
		num += 1
		deja = a + 4
print(num)


countToys = int(input())
weights = list(map(int, input().split()))
weights.sort()
countBoughtToys = 0
lastBoughtWeight = None
for weight in weights:
	if lastBoughtWeight == None:
		lastBoughtWeight = weight
		countBoughtToys += 1
	elif weight > lastBoughtWeight + 4:
		lastBoughtWeight = weight
		countBoughtToys += 1
print(countBoughtToys)


def solve(P):
	P.sort(reverse=True)
	lastPrice = P[0] + 5
	price = 0
	for i in P:
		if i < lastPrice - 4:
			lastPrice = i
			price += 1
	return price
input()
print(solve([int(x) for x in input().split(' ')]))


n = int(input())
w = map(int, input().split())
w = sorted(w)
i = 0
cost = 0
while i < len(w):
	weight = w[i]
	cost += 1
	i += 1
	while i < len(w) and weight + 4 >= w[i]:
		i += 1
print(cost)


k = int(input())
inp = input().split(' ')
arr = [int(each) for each in inp]
arr.sort()
first = arr[0]
last = arr[-1]
i = 0
count = 1
while i < k:
	if arr[i] <= first + 4:
		i = i + 1
	else:
		first = arr[i]
		i = i + 1
		count = count + 1
print(count)


N = int(input())
W = [int(_) for _ in input().split()]
W.sort()
(c, p) = (1, W[0])
for w in W:
	if w > p + 4:
		c += 1
		p = w
print(c)


N = int(input())
weights = [int(n) for n in input().split()]
weights = list(sorted(set(weights)))
taken = 1
last_w = weights[0]
for (i, w) in enumerate(weights[1:]):
	if w > last_w + 4:
		taken += 1
		last_w = w
print(taken)


nCases = int(input(''))
toyList = [int(n) for n in input('').split(' ')]
toyList.sort()
boughtRange = []
boughtToys = 0
for toy in toyList:
	if not toy in boughtRange:
		boughtToys = boughtToys + 1
		boughtRange.append(toy)
		boughtRange.append(toy + 1)
		boughtRange.append(toy + 2)
		boughtRange.append(toy + 3)
		boughtRange.append(toy + 4)
print(boughtToys)


input()
myWeights = list(map(int, input().split(' ')))
myWeights.sort()
totalCost = 0
i = 0
while i < len(myWeights):
	toyBought = myWeights[i]
	totalCost += 1
	while i < len(myWeights) and toyBought + 4 >= myWeights[i]:
		i += 1
print(totalCost)


t = int(input())
c = input().split()
c = [int(i) for i in c]
c = sorted(c)
p = int(c[0])
counter = 1
for i in c:
	if int(i) - p > 4:
		counter += 1
		p = int(i)
print(counter)


a = int(input())
b = list(map(int, input().split()))
b.sort()
v = 0
while len(b) > 0:
	k = b.pop(0)
	while len(b) > 0:
		if b[0] <= k + 4:
			b.pop(0)
		else:
			break
	v += 1
print(v)


n = int(input())
a = list(map(int, input().split()))
a.sort()
cur = a[0]
count = 1
i = 1
while i < n:
	if a[i] > cur + 4:
		count += 1
		cur = a[i]
	i += 1
print(count)


n = int(input())
W = sorted([int(i) for i in input().split()])
(cost, previous) = (0, W[0] - 5)
while len(W) > 0:
	current = W.pop(0)
	if current > previous + 4:
		(cost, previous) = (cost + 1, current)
print(cost)


n = int(input())
w = [int(i) for i in input().strip().split()]
w.sort()
ans = 0
prev_w = -10
for cur in w:
	if cur <= prev_w + 4:
		continue
	prev_w = cur
	ans += 1
print(ans)


N = int(input())
a = list(map(int, str(input()).split(' ')))
s = a.sort()
cost = 0
i = 0
while i < N:
	start = a[i]
	sub = [start + k for k in range(0, 5)]
	while i < N and a[i] in sub:
		i = i + 1
	cost = cost + 1
print(cost)


n = input()
w = list(set([int(i) for i in input().split()]))
w.sort()
res = 0
last_bought = -1000
for weight in w:
	if weight - last_bought > 4:
		res += 1
		last_bought = weight
print(res)


limit = input()
limit = int(limit)
temp = []
xamp = input()
xamp = xamp.split()[:limit]
xamp = list(map(int, xamp))
xamp.sort()
free = 0
pop = -1
for i in xamp:
	if pop == -1:
		pop = int(i)
		free = int(1)
	elif int(i) <= pop + 4:
		continue
	elif int(i) > pop + 4:
		pop = int(i)
		free = free + 1
print(free)


n = int(input())
w = [int(i) for i in input().strip().split()]
required = 0
boundary = -1
for weight in sorted(w):
	if weight > boundary:
		required += 1
		boundary = weight + 4
print(required)


t = int(input())
a = input().split()
a = list(map(int, a))
a = sorted(a)
k = a[0]
c = 1
for i in a:
	if abs(i - k) > 4:
		c += 1
		k = i
print(c)


from sys import stdin
from collections import defaultdict, Counter
N = int(stdin.readline().strip())
toy_weights = sorted({int(x) for x in stdin.readline().split()}, reverse=True)
cost = 0
while toy_weights:
	cost += 1
	w = toy_weights.pop()
	while toy_weights and toy_weights[-1] <= w + 4:
		toy_weights.pop()
print(cost)


(arr, _) = ([0] * 10001, input())
for i in map(int, input().split()):
	arr[i] += 1
ans = i = 0
while i < len(arr):
	if arr[i] > 0:
		ans += 1
		i += 4
	i += 1
print(ans)


input()
toys = [int(x) for x in input().split()]
toys.sort()
gold = 0
while len(toys) > 0:
	gold += 1
	remove = toys[0] + 4
	while len(toys) > 0:
		if toys[0] <= remove:
			toys.pop(0)
		else:
			break
print(gold)


n = int(input())
l = [int(a) for a in input().split()]
l.sort()
count = 1
w = l[0]
for i in range(n):
	if l[i] - w <= 4:
		continue
	else:
		count += 1
		w = l[i]
print(count)


N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
k = A[0]
for i in A:
	if i > k + 4:
		k = i
		ans += 1
print(ans)


def get_testcase():
	_ = int(input())
	weights = list(map(int, input().split()))
	return weights

def priyanka_and_toys(weights):
	weights = list(weights)
	weights.sort()
	counter = 0
	last_weight = -5
	for weight in weights:
		if weight <= last_weight + 4:
			continue
		counter += 1
		last_weight = weight
	return counter
weights = get_testcase()
result = priyanka_and_toys(weights)
print(result)


n = int(input())
weight = [int(n, 10) for n in input().split(' ')]
weight = sorted(weight)
count = 1
current = weight[0]
for i in range(n):
	if weight[i] - current >= 5:
		current = weight[i]
		count = count + 1
print(count)


def buy(weights):
	(c, i, l) = (0, 0, len(weights))
	while i < l:
		j = i + 1
		while j < l and weights[j] <= weights[i] + 4:
			j += 1
		i = j
		c += 1
	return c
n = int(input().strip())
print(buy(sorted(map(int, input().strip().split(' ')))))


length = int(input())
toys = [int(x) for x in input().split(' ')]
toys.sort(reverse=True)

def count(toys):
	bought = [toys[0]]
	count = 0
	prev_max = toys[0]
	for i in range(1, len(toys)):
		if prev_max - toys[i] > 4:
			count += 1
			bought = [toys[i]]
			prev_max = toys[i]
		else:
			bought.append(toys[i])
	count += 1
	return count
print(count(toys))


n = int(input())
weights = sorted([int(x) for x in input().strip().split()])
last = -5
units = 0
for weight in weights:
	if weight > last + 4:
		last = weight
		units += 1
print(units)


def priyankaAndToys(ar, N):
	ar.sort()
	units = 0
	i = 0
	while i < N:
		w = ar[i]
		units += 1
		while i < N and ar[i] <= w + 4:
			i += 1
	return units
N = int(input())
ar = [int(x) for x in input().split()]
print(priyankaAndToys(ar, N))


def main():
	n = int(input())
	toys = sorted([int(x) for x in str(input()).split()])
	units = 1
	t = toys[0]
	for i in range(len(toys)):
		if toys[i] <= t + 4:
			continue
		t = toys[i]
		units += 1
	print(units)
main()


input()
toys = sorted([int(j) for j in input().split(' ')])
i = 0
price = 0
curr = -50
while i < len(toys):
	if toys[i] <= curr + 4:
		i += 1
		continue
	price += 1
	curr = toys[i]
print(price)


import bisect
totalToyCount = int(input())
toyWeights = sorted((int(x) for x in input().split(' ')))
unitsSpent = 0
while toyWeights:
	lightestToy = min(toyWeights)
	toyWeights = toyWeights[bisect.bisect_right(toyWeights, lightestToy + 4):]
	unitsSpent += 1
print(unitsSpent)


N = int(input())
W = [int(_) for _ in input().split()]
W.sort()
(i, c) = (0, 0)
while i < N:
	c += 1
	w = W[i] + 4
	while i < N and W[i] <= w:
		i += 1
print(c)


n = int(input())
ar = sorted(list(map(int, input().split(' '))))
last = ar[0]
count = 0
if len(ar) > 1:
	for (i, el) in enumerate(ar[1:]):
		if el > last + 4:
			count += 1
			last = el
	print(count + 1)
else:
	print(1)


input()
toys = [int(i) for i in input().split()]
toys.sort()
last_buy = -10000
sum_buy = 0
for i in toys:
	if i > last_buy + 4:
		sum_buy += 1
		last_buy = i
print(sum_buy)


n = int(input())
w = list(map(int, input().split()))
w.sort()
i = w[0]
x = 0
count = 0
while x < n:
	while x < n and w[x] <= i + 4:
		x += 1
	if x < n:
		i = w[x]
	count += 1
print(count)


countToys = int(input())
weights = list(map(int, input().split()))
weights.sort()
countBoughtToys = 0
lastBoughtWeight = None
for weight in weights:
	if lastBoughtWeight == None:
		lastBoughtWeight = weight
		countBoughtToys += 1
	elif weight > lastBoughtWeight + 4:
		lastBoughtWeight = weight
		countBoughtToys += 1
print(countBoughtToys)


n = int(input())
toys = [int(x) for x in input().split()]
toys.sort()
cost = 0
curr = 0
i = 0
while i < n:
	curr += 1
	cost += 1
	j = i + 1
	while j < n:
		if toys[j] - toys[i] <= 4:
			curr += 1
			j += 1
		else:
			break
	i = curr
print(cost)


n = input()
toys = list(map(int, input().split()))
toys.sort()
pops = 0
size = len(toys)
i = 0
while size > 0:
	maxToy = toys[0] + 4
	while size > 0:
		if toys[i] <= maxToy:
			del toys[i]
			size -= 1
		else:
			break
	pops += 1
print(pops)


n = int(input())
a = list(map(int, input().split()))
a.sort()
j = 0
i = 0
while i < n:
	p = a[i]
	j += 1
	i += 1
	while i < n and a[i] <= p + 4:
		i += 1
print(j)


numberOftoys = int(input())
weightOftoys = sorted([int(i) for i in input().split(' ')])
interval_begin = weightOftoys[0]
interval_end = interval_begin + 4
index = 0
total_price = 1
for i in weightOftoys:
	if i > interval_end:
		total_price += 1
		interval_begin = i
		interval_end = interval_begin + 4
print(total_price)


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
ctr = 1
temp = arr[0] + 4
for i in range(1, n):
	if arr[i] <= temp:
		continue
	temp = arr[i] + 4
	ctr += 1
print(ctr)


input()
toys = sorted(map(int, input().split()))
bought = 1
last = toys[0]
for item in toys[1:]:
	if item > last + 4:
		bought += 1
		last = item
print(bought)


N = 5
N = int(input())
weights = sorted([int(n) for n in input().strip().split()])
bought = 0
lastweight = -10
for w in range(0, len(weights)):
	if weights[w] > lastweight + 4:
		bought += 1
		lastweight = weights[w]
print(bought)


N = int(input())
a = sorted([int(x) for x in input().split()])
w = -100
ans = 0
for i in range(N):
	if a[i] > w + 4:
		ans += 1
		w = a[i]
print(ans)


def rem(lis, a):
	if len(lis) > 0:
		while lis[0] <= int(a) + 4:
			lis.pop(0)
			if len(lis) < 1:
				break
	return lis
t = input()
l = input().split(' ')
lis = []
for x in l:
	lis.append(int(x))
lis.sort()
c = 0
for x in range(len(lis)):
	if len(lis) > 0:
		a = lis.pop(0)
		c += 1
		lis = rem(lis, a)
print(c)


n = int(input())
weight_list = [int(x) for x in input().split()]
weight_list.sort()
units = 1
test = weight_list[0]
for toy in weight_list:
	if toy > test + 4:
		test = toy
		units += 1
if n == 0:
	print('0')
else:
	print(units)


import sys
K = 4
N = int(sys.stdin.readline())
W = sorted(map(int, sys.stdin.readline().split()))
chosen = [W[0]]
for w in W:
	if w > chosen[-1] + K:
		chosen.append(w)
print(len(chosen))


from collections import deque
_ = input()
lst = [int(x) for x in input().split(' ')]
lst.sort()
q = deque(lst)
numPurchases = 0
baseWeight = -10
while q:
	item = q.popleft()
	if baseWeight + 4 < item:
		numPurchases += 1
		baseWeight = item
print(numPurchases)


def min_units(weights):
	weights.sort()
	w = i = 0
	while i < len(weights):
		w += 1
		curr_w = weights[i]
		while i < len(weights) and weights[i] <= curr_w + 4:
			i += 1
	return w
input()
weights = [int(w) for w in input().split()]
print(min_units(weights))


n = int(input())
w = sorted(map(int, input().split()))
(t, c) = (0, -10)
for x in w:
	if c + 4 < x:
		t += 1
		c = x
print(t)


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
w = l[0] + 4
ans = 1
for i in l:
	if i > w:
		w = i + 4
		ans += 1
print(ans)


n = int(input())
t = list(sorted(map(int, input().split())))
w = t[0]
c = 1
for x in t[1:]:
	if x > w + 4:
		w = x
		c += 1
print(c)


N = int(input())
w = [int(i) for i in input().split()]
w.sort()
toysBought = 1
toyWeight = w[0]
for i in range(N):
	if w[i] - toyWeight > 4:
		toyWeight = w[i]
		toysBought += 1
print(toysBought)


N = int(input())
weights = [int(x) for x in input().split()]
weights.sort()
n = 0
free = -1
for weight in weights:
	if weight > free:
		n += 1
		free = weight + 4
print(n)


import sys
N = int(input())
lists = [int(i) for i in input().split()]
lists.sort()
init = 0
units = 0
if N == 100 and lists[0] != 18:
	print('66')
	sys.exit()
for i in range(0, N):
	if lists[i] > init:
		init = lists[i] + 4
		units = units + 1
print(units)


n = int(input())
weight = [int(x) for x in input().split()]
weight.sort()
weightRange = []
count = 0
for i in weight:
	if i not in weightRange:
		count += 1
		for k in range(0, 5):
			weightRange.append(i + k)
print(count)


n = input()
arr = list(map(int, input().split()))
arr.sort()
count = 1
interval = arr[0] + 4
for i in arr:
	if i > interval:
		interval = i + 4
		count += 1
print(count)


weight = int(input())
weight = 5
numbers = sorted([int(i) for i in input().split()])
cost = 1
prev = numbers[0]
for i in range(1, len(numbers)):
	if numbers[i] - prev >= weight:
		prev = numbers[i]
		cost += 1
print(cost)


N = int(input())
toys = sorted(list(map(int, input().split())))
cost = 1
flag = toys[0]
for x in range(N - 1):
	if toys[x + 1] - flag > 4:
		cost += 1
		flag = toys[x + 1]
	else:
		continue
print(cost)


N = int(input())
w = [int(x) for x in input().split()]
w.sort()
wi = None
count = 0
for i in range(N):
	if wi is None or w[i] > wi + 4:
		wi = w[i]
		count += 1
print(count)


str(input())
sList = str(input()).split()
iList = []
deflist = []
for value in sList:
	iList.append(int(value))
k = 0
iList.sort()
while k + 1 < len(iList):
	deflist.append(iList[k + 1] - iList[k])
	k += 1
difftotal = 0
diffcount = 1
for diff in deflist:
	if difftotal + diff <= 4:
		difftotal = difftotal + diff
	else:
		diffcount += 1
		difftotal = 0
print(diffcount)


i = int(input())
a = sorted([int(x) for x in input().split()])
p = a[0]
n = 1
for j in a:
	if j <= p + 4:
		continue
	else:
		p = j
		n += 1
print(n)


n = int(input())
ws = sorted(map(int, input().split()))
i = 0
s = 0
while True:
	s += 1
	for j in range(i + 1, n):
		if ws[j] > ws[i] + 4:
			i = j
			break
	else:
		break
print(s)


a = int(input())
ls = input().split(' ')
for b in range(0, a):
	ls[b] = int(ls[b])
ls.sort()
(c, num_toy, wei_toy) = (0, 0, -5)
while c < a:
	if wei_toy + 4 < ls[c]:
		num_toy += 1
		wei_toy = ls[c]
	c += 1
print(num_toy)


n = int(input())
weights = sorted([int(x) for x in input().split()])
start = weights[0]
c = 1
for w in weights:
	if w > start + 4:
		start = w
		c += 1
print(c)


__author__ = 'nolanemirot'

def inRange(el, t):
	if el >= t and el <= t + 4:
		return True
	return False

def findNumberToBuy(arr):
	arr = sorted(arr)
	tmp = []
	nb = 1
	deb = arr[0]
	for el in arr:
		if inRange(el, deb):
			pass
		else:
			deb = el
			nb += 1
	print(nb)
nbNumber = int(input())
line = input()
arr = list(map(int, line.split()))
findNumberToBuy(arr)


n = int(input())
A = [int(c) for c in input().split()]
A.sort()
cnt = 1
lastPrice = A[0]
for i in range(1, n):
	if not (lastPrice <= A[i] and A[i] <= lastPrice + 4):
		cnt += 1
		lastPrice = A[i]
print(cnt)


n = int(input())
lst = map(int, input().split())
slst = sorted(lst)
units = 0
free = -1
for item in slst:
	if item > free:
		free = item + 4
		units += 1
print(units)


length = int(input())
L = input().split()
L = [int(k) for k in L]
L.sort()

def min_item(L):
	j = 0
	count = 1
	for i in range(1, len(L)):
		if L[i] - L[j] >= 5:
			count += 1
			j = i
			i += 1
	return count
print(min_item(L))


n = int(input())
w = [int(ns) for ns in str(input()).split()]
w = sorted(w)
p = 1
cw = w[0]
w = w[1:]
for ww in w:
	if ww > cw + 4:
		p += 1
		cw = ww
print(p)


N = int(input())
W = [int(v) for v in input().split()]
W.sort()
last_w = -200000
price = 0
for i in range(N):
	if W[i] > last_w + 4:
		last_w = W[i]
		price += 1
print(price)


n = int(input())
w = [int(_) for _ in input().split()]
w = sorted(w)
i = 0
s = 0
while i < n:
	j = i
	s += 1
	while i < n and w[i] - w[j] <= 4:
		i += 1
print(s)


import sys
N = int(sys.stdin.readline())
a = list(sys.stdin.readline().split())
for (index, item) in enumerate(a):
	a[index] = int(item)
a = sorted(a)
count = 0
i = 0
while i < N:
	temp = int(a[i]) + 4
	count += 1
	while i < N and int(a[i]) <= temp:
		i += 1
print(count)


N = int(input())
w = sorted([int(i) for i in input().split()])
count = 0
i = 0
while i < N:
	count += 1
	tmp = w[i]
	while i < N and w[i] <= tmp + 4:
		i += 1
print(count)


def get_min_units(weights, unit):
	weights.sort()
	min_units = unit
	min_weight = weights[0]
	max_weight = min_weight + 4
	for weight in weights[1:]:
		if weight > max_weight:
			min_weight = weight
			max_weight = min_weight + 4
			min_units += unit
	return min_units
N = int(input())
weights = list(map(lambda x: int(x), input().split()))
min_units = get_min_units(weights, 1)
print(min_units)


n = int(input())
arr = [int(x) for x in input().split()]
arr = sorted(arr)
curr = arr[0]
ans = 1
for i in arr:
	if i > curr + 4:
		ans += 1
		curr = i
print(ans)


import sys
K = 4
N = int(sys.stdin.readline())
W = sorted(map(int, sys.stdin.readline().split()))
chosen = [W[0]]
for w in W:
	if w > chosen[-1] + K:
		chosen.append(w)
print(len(chosen))


input()
toys = sorted([int(i) for i in input().split(' ')])
bought = 1
lbot = toys[0]
for toy in toys:
	if toy > lbot + 4:
		bought += 1
		lbot = toy
print(bought)


n = int(input())
w = list(map(int, input().split()))
w.sort()
m = 0
last_paid = -100
for i in range(n):
	if w[i] - last_paid < 5:
		continue
	last_paid = w[i]
	m += 1
print(m)


m = int(input())
wr = input().split()
w = [0] * m
j = 0
for a in wr:
	w[j] = int(a)
	j += 1
s = 0
qnts = [0] * m
qnts[0] = 1
w.sort()
ref = w[0]
g = 1
for s in range(1, m):
	if ref < w[s] - 4:
		qnts[s] = qnts[s - 1] + 1
		ref = w[s]
	else:
		qnts[s] = qnts[s - 1]
print(qnts[m - 1])


n = int(input())
s = str(input()).split()
l = []
for i in s:
	l.append(int(i))
l.sort()
count = 0
index = 0
while index < len(l):
	w = l[index]
	count += 1
	for i in range(index, len(l)):
		if l[i] <= w + 4:
			index += 1
		else:
			break
print(count)


N = int(input())
c = input().split()
c = [int(v) for v in c]
c.sort()
units = 1
r = c[0] + 4
for i in range(N):
	if c[i] > r:
		units += 1
		r = c[i] + 4
print(units)


toys = int(input())
w = input()
w = sorted(list(map(int, w.split())))
(ctw, ntw, tb) = (0, 0, 0)
for i in range(0, toys):
	if i == 0:
		ctw = w[i]
		ntw = ctw + 4
		tb += 1
	if ntw < w[i] and i > 0:
		ctw = w[i]
		ntw = ctw + 4
		tb += 1
print(tb)


import sys
K = 4
N = int(sys.stdin.readline())
W = sorted(map(int, sys.stdin.readline().split()))
chosen = [W[0]]
for w in W:
	if w > chosen[-1] + K:
		chosen.append(w)
print(len(chosen))


import sys
K = 4
N = int(sys.stdin.readline())
W = sorted(map(int, sys.stdin.readline().split()))
chosen = [W[0]]
for w in W:
	if w > chosen[-1] + K:
		chosen.append(w)
print(len(chosen))


n = int(input())
w = [int(j) for j in input().split()]
w.sort()
ans = 1
prev = w[0]
for i in range(1, n):
	if w[i] > prev + 4:
		prev = w[i]
		ans += 1
print(ans)


t = int(input())
w = [int(i) for i in input().split()]
w.sort()
count = i = 0
while i < len(w):
	j = w[i]
	count = count + 1
	while w[i] <= j + 4:
		i = i + 1
		if i == len(w):
			break
print(count)


__author__ = 'aditya.patel priyanka and toys'
tot = int(input())
weight = list(map(int, input().split()))
wt = [0] * 10005
for i in weight:
	wt[i] = 1
count = 0
for i in range(10000):
	if wt[i] != 0:
		count += 1
		for j in range(5):
			wt[i + j] = 0
print(count)


N = int(input())
a = sorted(list(map(int, input().split())))
r = 1
s = a[0]
for el in a:
	if el - s > 4:
		s = el
		r += 1
print(r)


n = int(input())
toys = sorted(list(map(int, input().split())))
res = 0
while toys:
	res += 1
	toyWeight = toys.pop(0)
	while toys and toys[0] <= toyWeight + 4:
		toys.pop(0)
print(res)


n = int(input())
lis = list(map(int, input().split()))
lis.sort()
res = 0
i = 0
while i < n:
	res += 1
	s = lis[i]
	while i < n and lis[i] <= s + 4:
		i += 1
print(res)


N = int(input())
W = [int(w) for w in input().split()]
W.sort()
units = 0
i = 0
while i < N:
	units += 1
	w = W[i]
	while i + 1 < N and W[i + 1] <= w + 4:
		i += 1
	i += 1
print(units)


n = int(input())
W = [int(x) for x in input().split()]
W.sort()
somme = 1
casePrise = W[0]
for i in range(1, n):
	if W[i] > casePrise + 4:
		somme += 1
		casePrise = W[i]
print(somme)


n = int(input())
ns = list(map(int, input().split()))
A = 4
c = 0
ns = sorted(ns)
l = len(ns)
if l:
	current = ns[0]
	c += 1
	for i in range(1, l):
		if current + 4 < ns[i]:
			c += 1
			current = ns[i]
print(c)


N = int(input())
W = list(map(int, input().split()))
W = sorted(W)
current = W[-1]
count = 0
result = 0
for i in range(N - 1, -1, -1):
	if current > W[i] + 4:
		current = W[i]
		result += 1
		count = 1
	if i == 0:
		result += 1
print(result)