Skip to main content
Back to problems
Codeforces
Easy
Math
Simulation
Straight <<A>>

Determine whether a given integer sequence forms a straight arithmetic progression with step 2.

Acceptance 0%
Problem Statement

Problem

You are given a sequence of integers. Your task is to determine whether the sequence is a valid “Straight <<A>>” sequence: each next value should differ from the previous one by exactly 2, and the sequence should progress consistently throughout.

In other words, for every adjacent pair, the difference must be the same, and that common difference must be 2.

Return whether the sequence satisfies this condition.

Input Format

  • The first line contains an integer n — the length of the sequence.
  • The second line contains n integers a1, a2, ..., an.

Output Format

  • Print YES if the sequence is a straight progression with common difference 2.
  • Otherwise, print NO.

Constraints

  • 1 <= n <= $10^{5}$
  • Values fit in 32-bit signed integers
Examples
Sample cases returned by the problem API.

Example 1

Input

4
1 3 5 7

Output

YES

Explanation

Every adjacent difference is 2, so the sequence is valid.

Example 2

Input

4
1 4 6 8

Output

NO

Explanation

The first difference is 3, so the sequence does not use a consistent step of 2.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.