#K43967. Find Pair with Given Sum

    ID: 27427 Type: Default 1000ms 256MiB

Find Pair with Given Sum

Find Pair with Given Sum

You are given an array of integers A and an integer X. Your task is to determine whether there exist two distinct elements in the array such that their sum equals X. In other words, you need to check if there exist indices i and j with i ≠ j such that:

\(A[i] + A[j] = X\)

If such a pair exists, output "Yes"; otherwise, output "No".

Note: The same element cannot be used twice unless it appears at least twice in the array.

inputFormat

The input is read from the standard input (stdin) with the following format:

  1. The first line contains an integer n, representing the number of elements in the array.
  2. The second line contains n space-separated integers, representing the array A.
  3. The third line contains an integer X, the target sum.

outputFormat

Output a single line to the standard output (stdout) with either "Yes" if there exist two distinct elements in the array whose sum is exactly X, or "No" if no such pair exists.

## sample
4
10 15 3 7
17
Yes