cswork / OAOpen practice workspace

AmazonOA #96

Count Possible Winners (All About Rewards :)

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyPrefix & Ranges

The champion gets n points, and the other places get n−1 down to 1 points. Count the participants who, after winning, have a total score at least equal to everyone else's no matter how the others are ranked. Ties for the top are allowed.

Input

The first line contains n (1..100000), and the second line contains n initial scores (0..100000).

Output

Output a single integer answer.

Example 1

Input:

3
1 3 4

Output:

2

Example 2

Input:

4
5 7 9 11

Output:

1

Example 3

Input:

3
8 10 9

Output:

2

Example notes

Example 1: score 3 wins and gets 6, tying the 6 that score 4 gets in second place, which still counts as the top; score 4 also qualifies, 2 in total. Example 2: only 11 is within 1 of the maximum score, so the answer is 1. Example 3: both 10 and 9 qualify, so the answer is 2.

Editorial

Loading solution…