#C9384. Longest Contiguous Arithmetic Subarray
Longest Contiguous Arithmetic Subarray
Longest Contiguous Arithmetic Subarray
Given an array of N integers, your task is to find the length of the longest contiguous arithmetic subarray.
An arithmetic subarray is a subarray where the difference between consecutive elements is constant. For example, the array [10, 7, 4, 6, 8, 10, 11] has an arithmetic subarray [4, 6, 8, 10] of length 4.
Mathematically, a subarray A[i], A[i+1], ..., A[j] is arithmetic if \[ A[k+1]-A[k] = d, \quad \text{for all } i \leq k < j \] for some constant difference \(d\). If the array contains fewer than 2 elements, define the longest arithmetic subarray length to be 0.
inputFormat
The first line contains an 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, the length of the longest contiguous arithmetic subarray.
## sample7
10 7 4 6 8 10 11
4
</p>