#K52277. Pair with Given Sum and Difference

    ID: 29274 Type: Default 1000ms 256MiB

Pair with Given Sum and Difference

Pair with Given Sum and Difference

You are given an array of integers and two integers x and y. Your task is to determine if there exists a pair of numbers a and b in the array such that:

\(a + b = y\) and \(a - b = x\).

This is equivalent to checking whether both \(a = \frac{y+x}{2}\) and \(b = \frac{y-x}{2}\) are integers. In the case where a and b are distinct, both must appear in the array. If a and b are equal (which can happen when x = 0), then the number must appear at least twice in the array.

Output True if such a pair exists and False otherwise.

inputFormat

The input is given 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.
  3. A line with two space-separated integers x and y, where x is the required difference and y is the required sum.

outputFormat

Output a single line containing either True or False (without quotes) to indicate whether such a pair exists.

## sample
5
1 5 3 4 2
2 5
True

</p>