#K3011. Arithmetic Sequence Formation
Arithmetic Sequence Formation
Arithmetic Sequence Formation
Given a list of integers, determine whether it is possible to rearrange them into an arithmetic sequence. An arithmetic sequence is defined as a sequence of numbers where the difference between consecutive terms is constant. Formally, a sequence a1, a2, ..., an is arithmetic if there exists a constant d such that for every i from 1 to n-1, ai+1 - ai = d. Note that sequences with less than two elements are always considered arithmetic.
inputFormat
The first line contains an integer n denoting the number of elements in the array. The second line contains n space-separated integers representing the array elements.
outputFormat
Output a single line: True
if the given list can be rearranged to form an arithmetic sequence, or False
otherwise.
3
3 5 1
True
</p>