#C3626. Pair Sum Existence

    ID: 47074 Type: Default 1000ms 256MiB

Pair Sum Existence

Pair Sum Existence

Given a list of integers and a target integer \(T\), determine if there exist two distinct elements in the list such that their sum equals \(T\). If such a pair exists, print YES; otherwise, print NO. Each element in the list can be used at most once.

Note: Two different indices must be used in forming the sum. For example, if the list has only one element, the answer will be NO even if double that element equals \(T\), as it does not constitute a valid pair.

inputFormat

The input is provided via standard input (stdin) and has the following format:

  • The first line contains a single integer \(n\) representing the number of elements in the list.
  • The second line contains \(n\) space-separated integers representing the elements of the list. If \(n = 0\), this line will be empty.
  • The third line contains a single integer \(T\) representing the target sum.

outputFormat

Output a single line to standard output (stdout) containing YES if there exists a pair of distinct elements whose sum equals \(T\); otherwise, output NO.

## sample
5
1 2 4 3 5
7
YES