#C2874. Can Form Arithmetic Sequence
Can Form Arithmetic Sequence
Can Form Arithmetic Sequence
Given an array of integers, determine whether its elements can be rearranged to form an arithmetic sequence. An arithmetic sequence is one in which the difference between any two consecutive elements is constant. In other words, for a sequence a1, a2, ..., an, there exists a constant d such that for all indices i (1 ≤ i < n),
\(a_{i+1} - a_i = d\)
The input is provided as follows: The first line contains the number of elements n (n ≥ 2). The second line contains n space-separated integers. Output "YES" if the array can be rearranged to form an arithmetic sequence, otherwise output "NO".
inputFormat
The first line contains an integer n (n ≥ 2), representing the number of elements in the array.
The second line contains n space-separated integers.
outputFormat
Output a single line containing "YES" if the array can be rearranged to form an arithmetic sequence, or "NO" otherwise.
## sample3
3 5 1
YES