Check Arithmetic Sequence

easy
1. You are given an array(arr) of integers.
2. You have to find if the elements of the given array can be arranged to form an arithmetic progression.
3. Arithmetic progression is defined as a sequence of numbers where the difference between any two consecutive numbers is the same. 

Note -> Try to solve this in linear time complexity.

Input Format

A number N arr1 arr2.. N numbers

Output Format

true/false

Constraints

1 <= N <= 10^6
1 <= arr[i] <= 10^3

Example

Input
3
3 5 1
Output
true
Previous
Maximum Points On A Line
Next
Smallest Subarray With All Occurrences Of The Most Frequent Element

Related Questions