#K40332. Pair with Given Sum

    ID: 26619 Type: Default 1000ms 256MiB

Pair with Given Sum

Pair with Given Sum

Given an integer target and a list of integers, determine whether there exists a pair of distinct indices \(i\) and \(j\) such that:

[ a_i + a_j = \text{target} ]

If such a pair exists, print YES; otherwise, print NO.

Note: Each pair must consist of two different elements. In other words, you cannot use the same array element twice.

inputFormat

The input is given via STDIN and has the following format:

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

outputFormat

Output a single line to STDOUT containing either YES if there exists a pair of distinct elements \(a_i\) and \(a_j\) such that \(a_i + a_j = \text{target}\), or NO otherwise.

## sample
5
5
1 2 3 4 5
YES