#K47117. Longest Prime Subarray
Longest Prime Subarray
Longest Prime Subarray
You are given an array of integers. Your task is to find the length of the longest contiguous subarray in which every element is a prime number. Formally, given an array ( A = [a_1, a_2, \dots, a_n] ), you need to determine the maximum integer ( L ) such that for some index ( i ) (with ( 1 \le i \le n-L+1 )), the subarray ( [a_i, a_{i+1}, \dots, a_{i+L-1}] ) consists entirely of prime numbers. If there is no prime number in the array, output 0.
inputFormat
The input is given via standard input. The first line contains a single integer ( n ) (the number of elements in the array). The second line contains ( n ) space-separated integers representing the elements of the array.
outputFormat
Output a single integer which is the length of the longest contiguous subarray that consists entirely of prime numbers. If no such subarray exists, output 0.## sample
10
1 2 3 4 5 6 7 8 9 10
2