Coalitions
시간 제한3초메모리 제한1024 MB
의석 합이 N의 절반을 넘으면서, 어느 한 정당을 빼면 합이 다시 절반 이하로 떨어지는 정당 집합의 수를 센다.
문제
There are members in the parliament, and each one of them is a representative of one of the parties. Now the parties have to form a ruling colation.
For a coalition to be able to rule, it needs a majority in the parliament. On the other hand, the more parties in the coalition, the less stable it is because of possible differences of opinion. Thus, a coalition that would still have a majority in the parliament after excluding some of the parties in it is not very sensible.
More precisely, a group of parties can form a stable coalition under two conditions:
- Together, the parties in the coalition have more than members of the parliament.
- If any of the parties were excluded from the coalition, the remaining ones would no longer have more than members of the parliament.
Count the number of possible groups that could form stable coalitions.
입력
The first line of input contains , the number of seats in the parliament, and , the number of parties (, ). The second line contains integers , , , (), where is the number of members of the parliament in the -th party. It is guaranteed that .
출력
The only line of output should contain a single integer: the number of possible stable coalitions.