#C3263. Pair with Sum

    ID: 46671 Type: Default 1000ms 256MiB

Pair with Sum

Pair with Sum

You are given an array of n integers and a target integer T. Your task is to determine if there exist two distinct indices i and j such that the sum of the corresponding elements equals the target.

In mathematical form, given an array \(A\) of size \(n\), find if there exist distinct indices \(i, j\) such that:

\(A_i + A_j = T\)

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

inputFormat

The first line of input contains an integer n denoting the number of elements in the array.

The second line contains n space-separated integers representing the elements of the array.

The third line contains an integer T which is the target sum.

outputFormat

Output a single line containing either YES if there exists a pair of distinct indices such that their sum equals T, or NO if no such pair exists.

## sample
5
1 2 3 4 5
9
YES