#K3431. Hopping Sequence Checker

    ID: 25281 Type: Default 1000ms 256MiB

Hopping Sequence Checker

Hopping Sequence Checker

You are given a sequence of n integers. The task is to determine whether the sequence is a Hopping Sequence. A sequence is called a Hopping Sequence if for each element (except the first and the last), the following condition holds:

$$2a_i = a_{i-1} + a_{i+1}$$

For sequences of length less than 3, they are always considered as Hopping Sequences.

Your task is to read the input sequence and print YES if it is a Hopping Sequence, otherwise print NO.

inputFormat

The input is given from standard input (stdin). The first line contains a single integer n indicating the number of elements in the sequence. The second line contains n space-separated integers representing the sequence.

outputFormat

Print a single line to standard output (stdout) with either YES if the sequence is a Hopping Sequence, or NO otherwise.## sample

5
1 2 3 4 5
YES

</p>