#SP0000228. Món quà của Chef (Cute Chef Gift)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Món quà của Chef (Cute Chef Gift)
Cute Chef Gift
Source: CodeChef
Version: Phuoc Hung OJ Extended
Problem Statement
Chef has a sequence of positive integers . He wants to split it after position . Let be the product of and the product of . The empty suffix when has product .
A split is valid if : no prime divides both products. Find the smallest valid index . The products can be enormous and need not be calculated explicitly.
Input
The first line contains . The second line contains exactly positive integers .
Output
Print the smallest split index such that and .
Subtasks
-
Subtask 1 (20 points): ; for every .
-
Subtask 2 (30 points): ; for every .
-
Subtask 3 (50 points): ; for every .
Examples
Input
4
2 3 4 5
Output
3
Explanation
For the array , cutting at gives products and , with gcd . At the products are and , again sharing factor . At the products are and , and . Thus the first valid split is .