## Cheerio Contest 1 J5 - Arithmetic Sequence

View as PDF

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 512M

Author:
Problem type

You are given a list of integers . Determine whether or not you can modify the list into an arithmetic sequence by rearranging the list and/or changing the value of at most number.

An arithmetic sequence is a sequence in which each term is obtained by adding the previous term by a constant number, called the first difference. For example, is an arithmetic sequence with a common difference of .

#### Constraints

• Points Awarded 6 points 5 points 4 points #### Input Specification

The first line contains one integer .

The second line contains integers .

#### Output Specification

Output YES if the list can be modified to become an arithmetic sequence and NO otherwise.

#### Sample Input 1

4
3 1 5 10

#### Sample Output 1

YES

#### Explanation for Sample Output 1

We can change the number in the list to be . The list of numbers becomes , which can be rearranged to form the arithmetic sequence .

#### Sample Input 2

5
3 6 9 12 15

#### Sample Output 2

YES

#### Explanation for Sample Output 2

The list is already an arithmetic sequence, so no changes are necessary.