#K55737. Arithmetic Progression Checker

    ID: 30042 Type: Default 1000ms 256MiB

Arithmetic Progression Checker

Arithmetic Progression Checker

You are given an integer n and a sequence of n integers separated by commas. Your task is to determine whether the sequence forms an arithmetic progression.

An arithmetic progression is defined by the formula \(a_{n} = a_{1} + (n-1)d\), where \(d\) is a constant difference between consecutive terms. If the sequence satisfies this relation, print "YES"; otherwise, print "NO".

Note that for a sequence of one element, it is trivially considered an arithmetic progression.

inputFormat

The input is provided via standard input (stdin) and consists of two lines:

  1. The first line contains an integer n, the number of elements.
  2. The second line contains n integers separated by commas (e.g., 1,3,5,7,9).

outputFormat

Output a single line to standard output (stdout): "YES" if the sequence is an arithmetic progression, and "NO" otherwise.

## sample
1
5
YES