#K82812. Making Sequence Elements Equal

    ID: 36059 Type: Default 1000ms 256MiB

Making Sequence Elements Equal

Making Sequence Elements Equal

You are given a sequence of N integers and an integer x. In one operation, you can increment or decrement any element of the sequence by x. Formally, an operation on element \(a_i\) is represented as:

[ a_i \to a_i \pm x ]

Your task is to determine whether it is possible to make all elements in the sequence equal by performing this operation any number of times (possibly zero).

A necessary and sufficient condition for this to be possible is that all elements in the sequence have the same remainder when divided by \(x\); that is, \(a_i \bmod x\) must be equal for all \(i\).

inputFormat

The input is read from stdin and has the following format:

N x
a1 a2 ... aN

Where:

  • N is the number of elements in the sequence.
  • x is the integer by which elements can be incremented or decremented.
  • a1, a2, ..., aN are the elements of the sequence.

outputFormat

Output a single line to stdout containing either YES if it is possible to make all elements equal, or NO otherwise.

## sample
3 2
4 2 2
YES