BRODOVI - BRODOVI

no tags 

Mirko lives in a small town with a harbour: once in a blue moon a ship passes by. However, to this day Mirko remembers the day when all the ships who had ever visited the harbour showed up. He denoted this day by index 1. Many days have passed since, but Mirko noted each day when at least one ship visited the harbour, naming these days entertaining. Additionally, Mirko has noticed that each ship visits the harbour periodically, at regular intervals. For instance, an interval of length 3 implies that some ship visited the harbour on days 1, 4, 7, 10 etc.

Given Mirko’s list of entertaining days (including today which is considered to be an entertaining day as well), compute the minimum possible number of ships visiting his harbour.

Notes: All entertaining days appear on Mirko’s list. It is guaranteed that the given data is consistent - in other words, a solution will always exist.

Input

The first line of input contains an integer N (2 ≤ N ≤ 5000), the number of entertaining days. The following N lines contain indices of entertaining days, one per line, in ascending order. The first and the last indices, representing the day from which Mirko started monitoring harbour traffic and today, respectively, will always appear on the list. The first index will always be 1, and the last one (index of today) will be less than 109.

Output

The first and only line of output must contain the required minimum number of ships.

Example

Input:
5
1
7
10
13
19

Output:
2

hide comments
Prateek Khandelwal: 2011-02-22 20:24:04

plz give me some more test cases....

Shizuo Heiwajima: 2011-02-19 01:37:39

O(n^2) algorithm is enough

Adrian Satja Kurdija: 2011-02-17 09:48:47

This problem can also be solved when N = 100 000. Feel free to set that problem on Spoj.

Kashyap Krishnakumar: 2011-02-17 05:49:44

Think simple :)

akaki: 2011-02-16 10:21:54

10^9

Mohamed Maher: 2011-02-15 21:41:05

i think 10^9

Last edit: 2011-02-16 10:22:06
:D: 2011-02-15 21:37:45

Most probably 10^9. It's the standard '^' missing issue :)

olimpoUS: 2011-02-15 19:23:29

The index of the day will be less than 109 or 10^9 ?.


Added by:akaki
Date:2011-02-15
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:coci