#C4573. Can Form Arithmetic Progression

    ID: 48126 Type: Default 1000ms 256MiB

Can Form Arithmetic Progression

Can Form Arithmetic Progression

You are given a list of integers. Your task is to determine if you can rearrange these numbers to form an arithmetic progression. An arithmetic progression is a sequence of numbers such that the difference between any two consecutive terms is constant. Formally, if the sorted array is (a_1, a_2, \dots, a_n), then the array forms an arithmetic progression if (a_{i+1} - a_i = d) for all valid (i), where (d) is a constant.

inputFormat

The input is read from standard input (stdin).\nThe first line contains an integer (n) representing the number of elements.\nThe second line contains (n) space-separated integers.

outputFormat

Output a single line to standard output (stdout) containing either True or False depending on whether the numbers can be rearranged to form an arithmetic progression.## sample

3
3 5 1
True