#C14744. Longest Contiguous Arithmetic Progression

    ID: 44427 Type: Default 1000ms 256MiB

Longest Contiguous Arithmetic Progression

Longest Contiguous Arithmetic Progression

You are given a sequence of integers. Your task is to find the length of the longest contiguous subsequence that forms an arithmetic progression.

An arithmetic progression is a sequence of numbers where the difference between consecutive elements is constant. Mathematically, for a sequence \( a_1, a_2, \dots, a_n \), it must hold that \( a_{i+1} - a_i = d \) for all \( 1 \leq i < n \), where \( d \) is a constant.

If the sequence is empty, the result is 0, and if the sequence contains only one element, the result is 1.

inputFormat

The input is provided from stdin in the following format:

  • The first line contains an integer \( n \) representing the number of elements in the sequence.
  • If \( n > 0 \), the second line contains \( n \) space-separated integers.

outputFormat

Output a single integer to stdout representing the length of the longest contiguous subsequence that forms an arithmetic progression.

## sample
0
0