Chotu and Kiss Day

4.3

18 votes
Very-Easy
Problem

"It all started with a kiss."

Chotu was up all night, planning for his first kiss. He has collected the data about all the kissing spots in Allahabad. According to his survey there are N kissing spots in the city, each spot i is associated with a security value Si. Chotu wants to visit as many spot as they can, but unfortunately the evil seniors hosted a contest on Kiss Day.
"Who on earth would code on kiss day!!" said Chotu. He tries to persuade his girlfriend to leave the contest but she being a true IIIT'an was determined to participate in the contest (kudos to the girlfriend).
Chotu is left with no other option but to replan his trip. He comes to a conclusion that if they visit more than three spots they will not be able to participate in the contest. So he decided to visit exactly three spots.

This is not the end of problems for Chotu. Allahabad is not a paradise for lovers. Bajrang Dal, a moral policing group is active in Allahabad, which is famous for troubling the couples during valentine week. But Chotu being intelligent has an escape plan. Bajrang Dal's aversion towards the number K is well known. Chotu knows that if the sum of the security factors of the three visited spots is K, then they will be safe.

Help Chotu find out whether he can safely celebrate Kiss Day or not.

Input
First line contains integer N denoting total number of kissing spots according to Chotu's survey.
Second line contains N distinct numbers separated by single space denoting the security value of N spots.
Third line contains integer K as explained above.

Output
Print YES if Chotu is able to find three places whose sum of security value is equal to given integer K else print NO.

Constraints
1 <= N <= 3*103
1 <= Security Value <= 109
1 <= K <= 109

Note - Chotu can visit each place only once.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

He can visit places with security value of 1, 7 and 9.

Editor Image

?