CF623B Array GCD

Description

You are given array $ a_{i} $ of length $ n $ . You may consecutively apply two operations to this array: - remove some subsegment (continuous subsequence) of length $ m

Input Format

The first line of the input contains integers $ n $ , $ a $ and $ b $ ( $ 1

Output Format

Print a single number — the minimum cost of changes needed to obtain an array, such that the greatest common divisor of all its elements is greater than $ 1 $ .

Explanation/Hint

In the first sample the optimal way is to remove number $ 3 $ and pay $ 1 $ coin for it. In the second sample you need to remove a segment $ [17,13] $ and then decrease number $ 6 $ . The cost of these changes is equal to $ 2·3+2=8 $ coins.