#C1173. Arithmetic Progression Rearrangement
Arithmetic Progression Rearrangement
Arithmetic Progression Rearrangement
Given a list of integers, determine if it is possible to rearrange them into an arithmetic progression. An arithmetic progression is defined as a sequence \(a_1, a_2, \dots, a_n\) in which there exists a constant difference \(d\) such that \(a_2 - a_1 = a_3 - a_2 = \dots = a_n - a_{n-1} = d\). Note that an empty sequence or a sequence with a single element is considered to form an arithmetic progression.
inputFormat
The input is read from standard input (stdin) and consists of two lines. The first line contains an integer \(n\) representing the number of elements in the sequence. The second line contains \(n\) space-separated integers.
outputFormat
Output a single line to standard output (stdout) containing either True
or False
. Output True
if the sequence can be rearranged to form an arithmetic progression, otherwise output False
.
3
3 5 1
True
</p>