#K75172. Arithmetic Progression Triplet
Arithmetic Progression Triplet
Arithmetic Progression Triplet
Given an array of integers, determine if there exists a triplet that forms an arithmetic progression. In other words, check whether there exist indices i, j, and k (with i < j < k) such that:
\(a[j] - a[i] = a[k] - a[j]\)
The array elements can be arranged in any order. You are required to read the array from the standard input and print either True
(if such a triplet exists) or False
(if it does not).
Note: Even if the numbers are not originally sorted, you may sort them before processing.
inputFormat
The first line contains a single integer n, representing the number of elements in the array.
The second line contains n space-separated integers representing the elements of the array.
You should read from standard input (stdin).
outputFormat
Output a single line: True
if there exists an arithmetic progression triplet in the array, otherwise False
.
The output should be printed to standard output (stdout).
## sample5
1 3 5 7 9
True