Under construction

Still being built. Things may change

Array and Operation

Interview

Time limit2sMemory limit512 MB

Summary
Given an array and a fixed K, decide if adding K to elements any number of times can turn it into a permutation of 1 to N.
Level

Easy3 of 10

Topics
Greedy, Hash map, Math, Implementation
Solved
No attempts yet

Problem

Yeongseon has an array AA of NN integers.

Only one operation applies to the array.

  • Choose one of the numbers in AA and add KK to it.

You can use this operation as many times as you want.

Given the array AA, write a program that decides whether the operation can turn AA into an array that contains every number from 11 to NN exactly once.

Input

The first line contains the array size NN and the integer KK. (1≤N≤501 \le N \le 50, 1≤K≤101 \le K \le 10)

The second line contains the NN elements of AA, separated by spaces. Each element is a natural number not greater than 5050.

Output

Print 11 if the operation can produce an array that contains every number from 11 to NN exactly once, and 00 otherwise.

Examples4

  1. Example 1

    Input
    4 3
    1 2 4 3
    
    Expected output
    1
    
  2. Example 2

    Input
    2 5
    2 2
    
    Expected output
    0
    
  3. Example 3

    Input
    8 1
    1 1 1 1 1 1 1 1
    
    Expected output
    1
    
  4. Example 4

    Input
    5 2
    5 3 3 2 1
    
    Expected output
    0