#K7511. Constant Sequence Score

    ID: 34347 Type: Default 1000ms 256MiB

Constant Sequence Score

Constant Sequence Score

You are given a sequence of n integers. The task is to determine if the sequence is an arithmetic progression. That is, whether the differences between consecutive elements are constant regardless of how much is added to all elements. In mathematical terms, an arithmetic progression satisfies the equation:

\(a_i = a_0 + i \cdot d \quad \text{for all } i\)

If the condition is met, print YES. Otherwise, print NO.

inputFormat

The input is read from stdin:

  • The first line contains an integer n, the length of the sequence.
  • The second line contains n space-separated integers representing the sequence.

outputFormat

Output a single line to stdout containing YES if the sequence forms an arithmetic progression, and NO otherwise.

## sample
3
1 3 5
YES

</p>