#K74547. Three Items Sum to Target

    ID: 34221 Type: Default 1000ms 256MiB

Three Items Sum to Target

Three Items Sum to Target

Given a list of n item prices and a target value \(T\), determine if there exists a combination of three distinct items such that the sum of their prices equals the target \(T\). In other words, you need to check whether there exist indices \(i, j, k\) (with \(i < j < k\)) that satisfy:

[ a_i + a_j + a_k = T ]

If such a combination exists, output YES; otherwise, output NO.

Note: The input is taken from standard input and the output is printed to standard output.

inputFormat

The first line contains an integer n, the number of items. The second line contains n space-separated integers representing the prices of the items. The third line contains an integer T, the target price.

Example:

7
10 15 3 7 8 12 5
22

outputFormat

Print a single line containing either YES if there exist three items whose prices sum up to T, or NO otherwise.

## sample
7
10 15 3 7 8 12 5
22
YES

</p>