Problem title
Difficulty
Avg time to solve

LCA of three Nodes
Easy
20 mins
Sum Of Infinite Array
Moderate
35 mins
Pair Sum
Easy
15 mins
Sum or Product
Easy
15 mins
Reverse The Array
Easy
15 mins
Flower Shop
Easy
--
Find Duplicate in Array
Easy
15 mins
Sort 0 1 2
Easy
22 mins
Two Sum
Easy
10 mins
Beautiful String
Easy
18 mins
439

Flower Shop

Difficulty: EASY

Problem Statement

Oasis visits a Florist Shop. Shop has N flowers each being of a specific type and every flower costs 1 unit.

You are given type of each flower in an array P = [p1,p2,...,pN]. If he buys a flower of type P’ , then he will get all flowers whose type lies between P’ to P’+4 (both inclusive) for free.

You need to find and print the price Oasis has to pay to buy all flowers.

Input Format
The first line contains an integer N i.e. number of flowers.
Next line will contain N integers, representing the types of N flowers.
Output Format
Print minimum cost with which Oasis could buy all of flowers.
Constraints

1 <= N <= 10^5

1 <= pi <= 10^4

Sample Input
5
1 2 3 17 10
Sample Output
3
Reset Code
Full screen
copy-code
Console