LCC '18 Contest 4 J1 - Terminus Quest

View as PDF

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

On his quest to solve Terminus Est, Max finds an ancient scroll that claims to be the key to solving the problem.

The scroll proclaims:

The one to solve Terminus Est shall be able to recognize patterns.

Max interprets this as the ability to recognize arithmetic patterns.

Max defines an arithmetic pattern as a list () of integers where the difference between any adjacent pair is the same.

The difference of an adjacent pair of integers is defined as for all , .

Can you determine if a list of numbers is an arithmetic pattern?

Input Specification

The first line contains a single integer, . .

The next line describes the list of numbers by providing space separated integers where the th integer describes .

Output Specification

YES if the input list is an arithmetic pattern. NO if the input list is not an arithmetic pattern.

Sample Input

5
2 4 6 8 10

Sample Output

YES