#C5018. Three Tickets Sum Challenge

    ID: 48621 Type: Default 1000ms 256MiB

Three Tickets Sum Challenge

Three Tickets Sum Challenge

You are given a target number t, an integer n representing the number of tickets, and a list of n ticket values. Your task is to determine whether it is possible to choose exactly three tickets (i.e. three distinct indices) such that their sum equals t. In other words, you need to check if there exist indices i, j, k with i < j < k satisfying \(ticket[i] + ticket[j] + ticket[k] = t\).

The input is given from stdin and the output should be printed to stdout.

inputFormat

The first line contains an integer t representing the target sum.
The second line contains an integer n representing the number of tickets.
The third line contains n space-separated integers representing the ticket values.

outputFormat

Output a single line with either "YES" if there exists a combination of three tickets whose sum is t, or "NO" otherwise.

## sample
15
5
1 2 4 8 9
YES

</p>