#K33417. Contains Pair with Given Difference

    ID: 25083 Type: Default 1000ms 256MiB

Contains Pair with Given Difference

Contains Pair with Given Difference

Given an array of integers and an integer k, determine whether there exist two distinct indices i and j such that the absolute difference between ai and aj is exactly k. In mathematical terms, you need to check if there exist i, j with i \neq j such that $$|a_i - a_j| = k.$$

It is guaranteed that the input array will contain at least one element. Your solution should read input from standard input (stdin) and output the result to standard output (stdout) as either True or False.

inputFormat

The input is provided via standard input in the following format:

  1. An integer n representing the number of elements in the array.
  2. A line with n space-separated integers representing the array elements.
  3. An integer k representing the required difference.

For example:

5
1 5 3 4 2
2

outputFormat

Output a single line to standard output, either True if there exists a pair of distinct indices such that the absolute difference between their corresponding values is k, or False otherwise.

## sample
5
1 5 3 4 2
2
True