#K79252. Forming an Arithmetic Progression

    ID: 35267 Type: Default 1000ms 256MiB

Forming an Arithmetic Progression

Forming an Arithmetic Progression

You are given a list of integers. Your task is to determine whether it is possible to form an arithmetic progression with at least three elements by removing some (or none) of the elements from the list. An arithmetic progression is a sequence in which the difference between consecutive elements is constant. In other words, for a sequence \(a_1, a_2, \dots, a_k\) with \(k \ge 3\), there exists a constant \(d\) such that \(a_{i+1} - a_i = d\) for all \(1 \le i < k\). If the given list has fewer than three integers, output False.

inputFormat

The first line contains a single integer (n) (the number of elements). The second line contains (n) space-separated integers representing the array.

outputFormat

Output True if there exists an arithmetic progression with at least three elements that can be formed by removing some or no elements, otherwise output False.## sample

5
3 5 1 7 9
True

</p>