We’re preparing your current view and syncing the latest data.
Given an array of integers, determine whether it's possible to rearrange the elements to form an arithmetic progression. An arithmetic progression is a sequence of numbers such that the difference between consecutive elements is constant. The program should output "YES" if such rearrangement is possible, otherwise "NO".
The first line contains an integer n — the number of elements in the array (1 ≤ n ≤ 10^5). The second line contains n integers a_i separated by spaces — the elements of the array (-10^9 ≤ a_i ≤ 10^9).
Output "YES" if it's possible to rearrange the array to form an arithmetic progression, otherwise output "NO".
1 ≤ n ≤ 10^5 -10^9 ≤ a_i ≤ 10^9
Example 1
Input
3 3 1 2
Output
YES
Explanation
After sorting, the array becomes [1, 2, 3], which is an arithmetic progression with difference 1.
Example 2
Input
4 1 2 4 6
Output
NO
Explanation
No rearrangement of the array forms an arithmetic progression.