Coprime Neighbors

Given a set of up to 50 distinct integers, insert the fewest new distinct positive integers so that consecutive values in sorted order are coprime.

Hard8MathNumber theoryGreedyDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

A set AA of NN distinct positive integers is given. Youngsun wants to put more positive integers into the set. After she is done, sort every number in the set in increasing order: the greatest common divisor of two neighboring numbers must not exceed 1. In other words, neighboring numbers in the sorted order must be coprime.

Write a program that finds the minimum count of numbers she has to put in. Every new number is a positive integer, and because AA is a set, a new number cannot equal a number that is already in it.

Input

The first line contains NN. (1N501 \le N \le 50)

The second line contains the NN numbers of the set, separated by spaces. Each number is a natural number not greater than 100,000, and all of them are distinct. They are not necessarily given in sorted order.

Output

Print the minimum count of numbers that must be put in on the first line.

Hint

One gap can need two new numbers. No integer strictly between 2184 and 2200 is coprime to both of them.