We need to parse the problem: n heroes, initial levels a_i. Each minute, a fight between two different heroes occurs, arbitrarily chosen (even same pair repeatedly). The outcome: if equal levels, nobody wins (i.e., both stay same). If different, higher level wins, and his level increases by 1. So essentially, the winner gains +1 level, the loser remains same.
We are interested in the first hero that wins at least M fights, where M = 100^{500}. That's an astronomically large number, essentially infinite for our practical considerations; it's extremely huge. So a hero can only be a possible winner if there is some sequence of fights (adversarial? Actually "exists a sequence of fights that this hero becomes the winner of the tournament." So we can choose the fights arbitrarily; but the condition is that this hero eventually reaches at least M wins before anyone else? The problem says: "The winner of the tournament is the first hero that wins in at least 100^{500} fights (note that it's possible that the tournament lasts forever if no hero wins this number of fights, then there is no winner)." So the tournament proceeds: each minute, we pick a fight (maybe by some external schedule? But we are to consider possible winners: a hero such that there exists a sequence of fights that this hero becomes the winner. So we can control the fights to try to make that hero the first to accumulate M wins. So we ask: is it possible, by appropriate choice of opponents at each step, to ensure that this hero reaches M wins before any other hero does? And if yes, then the hero is a possible winner.
So we need to determine for each hero, under optimal selection of fights (we control the fights, but presumably the opponents are chosen arbitrarily by us, we can also decide to have other heroes fight among themselves, etc.), can we make that hero be the first to achieve M wins? M is huge, but maybe we can think asymptotically: Since M is extremely large, essentially we need to see if a hero can accumulate arbitrarily many wins (i.e., his level can increase arbitrarily) while preventing others from reaching M wins. Since the tournament stops at the first hero who gets M wins, we want that hero to be the one.
But note that if a hero can potentially keep winning fights and increase his level, he can eventually get many wins. However, other heroes could also potentially win fights and increase their wins count. So we need to strategize: we can choose which heroes fight each other each minute. The goal is to make a particular hero the first to reach M wins. If it's impossible to prevent others from also reaching M wins before or simultaneously? Actually "first hero that wins in at least M fights" – so if two heroes reach M at the same time? But each minute only one fight occurs, so only one hero can win that fight (or none if tie). So wins increments are one per fight (only the winner gets +1 win count). So to reach M wins, a hero needs to be the winner in M fights. Since fights occur one at a time, only one hero can get the M-th win; it's impossible for two to reach M exactly at the same time because they would need separate fights. However, it's possible that while we are trying to make hero A reach M, hero B might also accumulate M wins before A's M-th win. We need to ensure that does not happen. So we must be able to schedule fights so that hero A's win count reaches M before any other hero's win count reaches M.
Given M is huge, essentially we need to ensure that hero A can get arbitrarily many wins while we can keep other heroes' win counts below M. But if other heroes have the potential to also get arbitrarily many wins, then we might be unable to prevent them from eventually reaching M before A if they have an advantage? But since we control the fights, we can avoid giving them wins. However, we cannot avoid that they might win when they fight each other? Actually we choose who fights each other; we can avoid letting other heroes win by never letting them fight against a lower-level opponent. But what about ties? If two other heroes have equal level, fighting each other results in no win for anyone. So we can avoid giving wins to others by only arranging fights where the hero we care about is the winner, or fights that result in draws, or fights where the intended winner is someone we control? However, note that if the hero we want to be winner fights, we can have him fight a lower-level opponent to win and increase his level. But as he wins, his level increases, making him even stronger. Meanwhile other heroes remain at their original levels (unless they also win). But we might need to have fights among others to perhaps adjust levels? But the goal is to ensure no other hero reaches M wins. So we can simply never let any other hero win a fight. Is that always possible? Possibly not, because if two other heroes have unequal levels and they fight, the higher one will win and increase his level, giving him a win. But we can choose to never make two unequal-level heroes fight. Instead, we could only have the intended hero fight against others, and for the rest, we could arrange only fights between equal-level heroes (draws) or maybe avoid fights altogether? However, we must have a fight each minute; the tournament proceeds indefinitely until someone wins. We can't skip minutes; we must choose a pair each minute. So we have to schedule fights continuously. If we want to avoid giving wins to others, we need to ensure that every fight not involving our hero results in a draw (i.e., equal levels) or perhaps have our hero participate in every fight? But there are multiple heroes; if we always have our hero fight, that would give him a win each time if we pair him with a lower-level opponent. But then his level increases; we can keep doing that. However, we need to consider that after some wins, his level may become so high that all others are lower, so any fight involving him would be a win for him (since his level > others). So we can always have him fight and win. That would give him a win each minute, and he would eventually reach M. Meanwhile, we must schedule fights each minute, and if we always have him fight, then we are using two heroes per fight: the hero and some opponent. But the opponent may also get no win (since loses). So that opponent does not get a win. However, after each fight, the opponent's level stays the same, but the hero's level increases. So after M fights, hero gets M wins. But the tournament stops at the moment he reaches M wins (i.e., after his M-th win). So we need to count the fights: if we do M fights each with him winning, then after the M-th win he becomes winner. However, note that we also need to consider the possibility that during those M fights, other heroes might also get wins if they participate as the lower-level? Actually they are the lower-level opponent and they lose, so they do not get a win. So they get zero wins. Therefore, they will never reach M wins. So this trivial strategy seems to work as long as we can always pick an opponent for him that he can beat. That is, as long as there is at least one other hero whose level is strictly less than his level at the time of the fight. Initially, if his level is not the maximum? Actually we need to check: The hero we want to win, call him A. If initially A is not the unique maximum? But we can arrange fights to increase his level. Suppose A's initial level is a_i. To win fights, he needs to be paired with someone whose level is less than his current level. If initially there is some hero with level less than a_i, then he can fight and win, increasing his level by 1. Then his level becomes a_i+1. Now maybe there are still heroes with level less than that? Possibly some heroes might have level equal to his new level, but those would be draws if they fight? But we can choose an opponent with strictly lower level. As long as there exists at least one hero with level less than his current level, he can win. If his level becomes so high that all other heroes have levels strictly less? Actually they can't be greater? But if there is another hero with higher level initially, that could be a problem: If there is a hero B with higher level than A, then initially A cannot beat B because A's level is lower. Could A still eventually become the winner? He might need to increase his level by winning against lower-level opponents until his level surpasses B. But if B's level is higher, A cannot win against B; but he can win against others with lower level. If B's level is the maximum and possibly there are multiple maxima. But as A wins, his level increases. If B's level is initially higher, but A can keep winning and eventually his level may surpass B's level, provided that B's level does not increase in the meantime. However, if B also gets wins, his level could also increase. Since we control fights, we can avoid giving B any wins. But can we avoid B getting wins? If we never let B fight someone with lower level. But what if B has the highest level initially? Then any fight between B and a lower-level hero (including A) would result in B winning if we pair them. But we can simply not pair B with any lower-level hero; we can keep B out of fights, or only pair B with heroes of equal or higher level? Actually if B is the highest level initially, there is no hero with higher level, so any opponent other than B will have level ≤ B's level. If we pair B with someone of strictly lower level, B would win and get a win. So to avoid that, we should not pair B with a lower-level opponent. We could pair B with someone of equal level (draw) or avoid B altogether. But we must have a fight each minute, and we can choose any two distinct heroes. So we could choose to always pair A with some lower-level hero, but if we need to avoid using B, that's fine: we can select A and some C (with lower level). But we need to ensure that for every minute, the fight involves two heroes. We can always use A and some other hero X that A can beat. However, what if at some point all heroes except A have levels >= A's current level? That would mean A cannot beat anyone. But initially, if there is a hero B with higher level, and maybe all other heroes have levels >= A? Actually if there is a hero with higher level, then A's level is not the maximum. But there might be heroes with lower level than A as well. For A to win, he needs at least one hero with level < A's current level. As he increases, eventually he might exceed the levels of all others, but at that point all others are lower, so he can beat any. The problematic situation is if there exists some hero with level strictly greater than A's current level, and all heroes with level less than A's current level have been exhausted? But "exhausted" not really; levels don't change except when they win. So if there is a hero with level higher than A, that hero's level is static unless it wins. So as A increases, he may eventually surpass that hero if the hero's level is finite and A can accumulate enough wins. However, while A is still below B's level, A can only beat heroes with level < A. That is possible as long as there is at least one hero with level < A. But what if all heroes other than A have level either equal to A or greater? If there are some equal, fighting them yields draw, no win. If there are greater, A cannot beat them. So if at some point, the set of heroes with level < A is empty, A cannot get any more wins. Then A would not be able to reach M. But could that happen? Initially, if A is the minimum level among all heroes, then there is no hero with level < A; A cannot win any fight initially because any opponent would have level ≥ A; if any opponent has equal level, draw; if higher, A loses. So A cannot get any win. So such a hero cannot be a possible winner. Similarly, if A is not the minimum but there are some heroes lower, A can win against them and increase his level. As he wins, his level goes up. The set of heroes with level < A may change because his level increases. Initially, there are some lower-level heroes. After each win, A's level increments by 1. Eventually, he might surpass all other heroes' levels, at which point all others are lower, so he can continue winning indefinitely. The only potential obstacle is if there is another hero B whose level is higher than A and that B also has the property that it is impossible for A to catch up because B might also be gaining levels? But we can prevent B from gaining levels by never letting B win. So B's level remains constant. Then A can win against lower-level heroes until his level exceeds B. However, as A's level increases, the lower-level heroes that A can beat might become fewer. But he only needs at least one hero with level < A at each step. Since B's level is constant, once A's level reaches B's level, then A cannot beat B (equal, draw), and if all other heroes have level <= A? Actually if A's level equals B's level, then A cannot beat B (draw), but he can still beat heroes with level < A. As long as there exists any hero with level < A, he can win. After A wins again, his level becomes B+1, which is > B. Then he can beat B as well. So the crucial condition is: Is there always at least one hero with level < A's current level at each step until A surpasses the max? This is equivalent to: At the start, there is at least one hero with level less than a_i. And as A's level increases, eventually he might run out of lower-level heroes if all other heroes have levels that are either equal to or greater than his current level. But consider the distribution: Let's sort levels. Suppose A starts at level x. Let the multiset of levels of other heroes be L. Initially, the number of heroes with level < x is some count. As A increases, his level becomes x+1, x+2, ... . The condition for him to be able to get another win is that there exists at least one other hero with level < current level. Since the other heroes' levels are fixed (unless they win, but we avoid that), the only way for all other heroes to have level >= current level is if current level <= min(other levels)? Actually we need at least one other hero with level < current level. So if current level is less than or equal to the minimum level among all other heroes, then no other hero has level < current. That would block further wins. So for A to eventually get arbitrarily many wins, we need that after some number of wins, A's level exceeds the minimum level among other heroes, and then as he increases further, eventually he will exceed all levels, but then all others are lower, so there will always be some lower-level hero (since n>=2, there is at least one other hero). Actually once his level exceeds the maximum of others, then all others have levels < his level, so he can beat any. So the only dangerous period is when his level is <= the minimum level among others. If initially his level is > min(other levels), then he can start winning. As he wins, his level increases, so it will always be > min(other levels) because min(other levels) is fixed. Actually min(other levels) is some constant m0. If initially a_i > m0, then after any number of wins, a_i + k > m0, so there is always at least one hero with level m0 < his level. So he can always win against that hero (or some other with level less than his). So he can keep winning indefinitely. If initially a_i = m0, i.e., his level equals the minimum among others? Actually if a_i equals the minimum level among all heroes (including himself?) But we consider other heroes. If a_i is the overall minimum? Then there is no other hero with level < a_i, so he cannot win initially. Could he somehow increase his level by other means? He cannot win because he would need to be the higher level in a fight; but he's the minimum, so any opponent is either equal or higher. If he fights someone equal, draw, no level change. If he fights someone higher, he loses; the winner gets +1 level, which would be the higher level hero, not him. So his level never increases if he is the minimum. So he can never get a win. Thus such a hero cannot be a possible winner.
But what about a hero that is not the minimum initially, but after some wins his level might become equal to the minimum? Actually if he's not the minimum initially, then his level > min(other). As he wins, his level increases, so it stays > min(other). So he never becomes minimum. So condition seems: For hero i to be a possible winner, his initial level must be strictly greater than the minimum level among all heroes? Wait, consider scenario where there are multiple heroes with the same minimum level. Suppose the minimum level in the whole set is m, and there are k heroes with level m. If our hero A has level m, then he is one of the minima. If he fights another hero with level m, it's a draw. If he fights a hero with level > m, he loses. So he cannot gain a win. So cannot be winner. So indeed, A must have level > min overall? But what if there is exactly one hero with level m, and that hero is A? Then min overall is m, and A's level = m, so cannot win. If there are multiple minima, A as a min cannot win either. So A must have level > min.
But is that sufficient? Consider scenario where there is a hero with a much higher level than A, but we can avoid giving that hero wins. However, is there any scenario where even though A > min, we cannot prevent some other hero from eventually reaching M wins before A? Since we control fights, we can avoid giving wins to others. But could it be forced that some other hero inevitably gets a win? Since we must schedule a fight each minute, we can always choose a pair that gives a win to A (if possible). But what if at some point, A cannot win because all other heroes have level >= A? But we argued that if A > min initially, then min(other) is some value m0 < a_i. Since others' levels are fixed (if we never let them win), then for any current level L of A (starting at a_i), we have L >= a_i > m0, so L > m0, so there is at least one hero with level m0 < L. So A can always win against that hero. So we can always schedule a fight where A beats that hero. That hero will lose, so no win for others. So we can keep doing that forever, and A will get arbitrarily many wins. Therefore, any hero whose initial level is greater than the global minimum is a possible winner. But wait, there is a nuance: After many such fights, the same opponent (the one with level m0) will lose many times, but its level stays unchanged because it loses. So that opponent's level remains m0. So A can keep beating that same opponent repeatedly? The rules don't forbid fighting the same pair repeatedly. So yes, A can fight the same low-level hero over and over, each time winning and increasing his level by 1. That is allowed. So indeed, if there exists at least one hero with level strictly less than A's initial level, A can win indefinitely by repeatedly fighting that hero. So A can accumulate M wins without any other hero getting any win. So A is a possible winner.
But is there any situation where even though A > min, there is some other hero that could also be forced to get wins because we need to have fights while A is still not the only one? Actually we can always choose the pair (A, some lower-level hero). So no need to involve other heroes. So we can keep doing that every minute. So A will reach M wins with no other hero ever winning. So that seems trivially sufficient.
Now, what about heroes that are initially at the minimum? Could they ever become winners? Possibly if they can first increase their level by some means other than winning? They cannot increase without winning. But could they win if they fight someone with equal level? No, draw. If they fight someone with higher level, they lose. So they cannot get a win at all. Thus they can never reach M wins. So they are not possible winners.
But consider scenario where all heroes have the same level. Then no hero can ever win any fight (all fights draw). So no one can reach M wins, tournament lasts forever, no winner. So answer = 0.
In the first example: levels [3,2,2]. Minimum = 2. Hero 1 has level 3 > 2 => possible winner. Heroes 2 and 3 have level 2 = min => not possible. Output = 1. Matches.
Second example: [5,5] all equal, min=5, both equal to min => none possible? But they can't win because draws. So answer 0 matches.
Third example: [1,3,3,7]. Minimum = 1. Heroes with level > min: all except the hero with level 1. So heroes 2,3,4 have levels 3,3,7 >1. So answer would be 3. Indeed output is 3.
So this suggests the answer is simply the number of heroes whose level is greater than the global minimum. But wait, is there any additional complexity? Let's test more cases.
Consider n=3, levels [2,2,3]. Global minimum = 2. Heroes with level > min: hero with 3 only. So answer = 1. Can hero with level 3 become winner? Yes, by repeatedly fighting one of the level-2 heroes. That works. Could a level-2 hero ever become winner? Initially both level-2 are at min. They can't win because any opponent: if they fight each other (2 vs 2) draw; if they fight the level-3, they lose. So they cannot get a win. So answer 1. That seems plausible.
Consider [1,2,100]. Minimum=1, heroes > min: 2 and 100 => 2 possible winners. Can the level-2 hero become winner? Yes, by repeatedly fighting the level-1 hero. But what about the level-100 hero? He can also become winner by fighting the level-1 hero repeatedly. So answer 2.
Consider [1,1,2]. min=1, >min: hero with 2 => 1. Good.
Consider [2,3,4]. min=2, >min: 3 and 4 => 2. But can the hero with level 3 become winner? Initially there is a lower-level hero: level 2, so he can beat level 2 repeatedly. However, there is also a higher-level hero: level 4. But he can avoid giving wins to level 4 by never pairing level 4 with a lower-level opponent. But does he need to involve level 4 in any fight? Since he can just fight level 2 repeatedly, level 4 never gets a chance to win. So yes, level 3 can become winner. Similarly, level 4 can also become winner by fighting level 2 repeatedly. So answer 2.
Consider [2,2,3,3]. min=2, >min: both level-3 heroes => 2. Could a level-2 hero become winner? They are at min, cannot win initially. Could they ever increase level? Perhaps if they fight each other? Draw. If they fight a level-3? They lose, level-3 wins and increases. So no. So not possible.
Now consider scenario where the minimum level hero is unique, but after some fights, that hero's level might increase if it wins? But it can't win initially because it's min. However, could it become non-min later by some indirect means? For it to win, it needs to be higher than opponent. But it's min, so any opponent is >=. If opponent is equal level, draw; if higher, lose. So it can't win. So it stays min forever. So indeed min heroes cannot ever get a win.
But what about a hero whose initial level is not the minimum, but there is a hero with even higher level that might be forced to win some fights if we try to avoid that? As argued, we can avoid entirely. So seems simple.
But wait, could there be a scenario where we need to consider that the tournament stops as soon as someone reaches M wins, and we want a particular hero to be the first. Suppose hero A and hero B both have initial levels > min. Could we schedule fights so that A reaches M first? Yes, by simply always letting A win. But could we also make B the winner? Yes, by always letting B win. So both are possible winners. So answer is all heroes except those at global minimum.
But is there any scenario where a hero at the global minimum could still be a possible winner if there is a way to get his level increased without winning? Perhaps if he fights someone with equal level and the fight results in a draw, levels unchanged. Or if he loses, he doesn't increase. So no. Unless the rules allow that when two equal fight, perhaps something else? No, "nobody wins the fight." So no change.
Thus answer seems simply count of heroes with level > min.
But wait, the problem statement says: "A possible winner is a hero such that there exists a sequence of fights that this hero becomes the winner of the tournament." This includes the possibility that the tournament might go on forever if no one reaches M, but we consider existence of a sequence that makes this hero the winner. So for a hero at min, can we conceive a sequence where he becomes the winner? He would need to reach M wins. Since he can never get a win, impossible. So not possible.
Thus solution appears trivial. But given the problem's M is huge, maybe there is more nuance: Could a hero with level > min still be unable to become winner because some other hero might inevitably get wins due to the requirement that we have to schedule fights each minute and we might be forced to sometimes let others fight? The problem says fights can be chosen arbitrarily, and it's even possible that the same two heroes fight during the last minute. So we have full control. So we can always choose the pair (A, some lower-level hero). That is allowed. So we never need to involve others. So it's fine.
But what if the lower-level hero is the minimum and there is only one such hero, and we keep beating him repeatedly. That is allowed. So no issue.
Thus answer is n - (count of heroes with minimum level). But is there any case where all heroes have the same level? Then answer 0, which matches n - n = 0.
Now, the problem's constraints: n up to 100, t up to 500. So trivial.
But I'm suspicious: This seems too trivial for a problem that mentions 100^{500} and such. Possibly there is a twist: The tournament ends when the first hero wins at least M fights. M is astronomically huge, but we can't simulate; however, the reasoning holds for any finite M. The condition "possible winner" might depend on whether the hero can accumulate arbitrarily many wins without others also reaching M due to forced interactions? But we argued we can avoid others winning.
Let's double-check if there is any hidden rule: "When two heroes of different levels fight, the one with the higher level wins, and his level increases by 1." So the winner's level increases by 1. The loser's level stays the same. The winner also gets a win count? The problem says "wins in at least 100^{500} fights". It doesn't explicitly say that winning a fight increments some counter, but it's implied that we track the number of fights each hero has won. So yes.
Now, could there be a scenario where the hero we want to win initially has level > min, but the only hero with level less than his is the global minimum, but that hero might eventually become equal to him if we keep beating him? No, the loser does not change. So his level remains min. So hero A's level keeps increasing, so always > min.
Thus always able to win.
But wait: What if there are multiple heroes at the minimum, and we want to use one of them as the perpetual loser. That works.
Thus answer is indeed number of heroes that are not the minimum.
But is there any scenario where a hero is the minimum but there exists a sequence where he eventually becomes not the minimum and then wins? For example, suppose we have levels [1,2]. Minimum is 1. Hero 1 can't win because he's lower. But could hero 1 become winner? If hero 2 fights hero 1, hero 2 wins, his level becomes 3. Hero 1 still 1. Then maybe later, if hero 2 fights hero 1 again, hero 2 wins again, etc. Hero 1 never wins. So no.
What about three heroes: [1,1,2]. Minimum is 1. Could a level-1 hero ever win? Possibly if two level-1 heroes fight, it's draw. If level-2 fights a level-1, level-2 wins. So level-1 never wins. So no.
Thus min cannot win.
Therefore, solution is count of elements > min.
But let's double-check the problem statement: "Each minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were fighting during the last minute)." So the selection of who fights is completely under our control. So we can always choose the pair (candidate, some lower-level hero). So candidate can always win.
But consider that the tournament may require that the fights are chosen by some process? The phrase "can be chosen arbitrarily" suggests that we, as the problem solver, can assume any sequence of fights we want to determine possible winners. So yes.
Thus answer is straightforward.
However, before finalizing, I'll think about any tricky cases. For instance, if there is a hero with level > min, but all heroes with lower level are also possible winners? That doesn't matter. Or if the minimum hero is also the only hero with lower level, can the candidate keep beating him forever? Yes.
But what about the condition that the tournament stops when a hero has at least M wins. Since M is huge, the candidate will need to win M fights. That means he will have to beat the same lower-level hero M times. Each time, the candidate's level increases by 1. The opponent's level remains the same. So after many beats, the candidate's level becomes huge, but the opponent stays at min. So there is no problem.
So answer = n - count(min).
But wait, is there any restriction that the same two heroes cannot fight consecutively? The statement says it's even possible that it is the same two heroes that were fighting during the last minute. So explicitly allowed.
Thus trivial.
But then why is M = 100^{500}? Possibly to emphasize that it's essentially infinite and we are not required to think about the actual number, just that a hero needs to win an enormous number of fights, meaning that we need to consider whether a hero can win arbitrarily many fights (i.e., have no upper bound on number of wins). Because if M were small, maybe a hero with level > min could be blocked by other heroes reaching M earlier due to forced interactions? But if M is huge, the ability to win arbitrarily many fights is the key. Actually, if M were 1, then any hero who can win at least one fight could be winner, but perhaps a min hero could also win if there is some sequence that gives him a win? But min hero cannot win any fight, so still no. So it's the same.
But maybe there is a nuance: Could there be a scenario where a hero with level > min cannot win arbitrarily many fights because at some point he might become unable to win due to all other heroes having level >= his? But we argued that if he is > min initially, then there is always at least one hero with level less than his (the global min) whose level is fixed. So his level will always be > that min, so he can always beat that hero. So indeed he can win arbitrarily many times.
But what if the global minimum hero is also the candidate? That fails. So yes.
But suppose the candidate's initial level is > min, but the only hero with level less than his is also a candidate? That doesn't matter.
Thus answer is count of heroes with level > min.
But wait, what about heroes that are exactly the minimum but there are multiple minima. Could they possibly win by having the other minima increase? For a minimum hero to win, it must at some point win a fight. For it to win a fight, it needs to be higher than its opponent. Could it ever become higher? Only by winning fights, which it cannot do initially. However, could it become higher if some other hero's level decreases? No, levels never decrease. So it can never become higher than any opponent that is currently >= its level. But maybe if it fights someone who later becomes lower due to some mechanic? Levels never decrease. So no.
Thus minima are hopeless.
Thus answer is n - freq(min).
But let's test edge cases: n=2, [1,2] => answer 1. n=2, [2,2] => answer 0. n=100, all levels 100 => 0.
Now, is there any case where a hero with level > min might still be impossible because we need to consider that the tournament could be infinite if no one reaches M, but we want to ensure that our candidate does reach M. If we can always schedule his wins, he will reach M in finite time. So ok.
But consider the possibility that while we are making the candidate win, we might inadvertently cause another hero to win because of some rule? No.
Thus final answer: For each test case, compute min value, count how many a_i > min.
But wait, the sample output for test case 3: [1,3,3,7] => min=1, >min count=3. matches.
Thus solution is trivial.
But I recall a Codeforces problem with similar description: "Arena" maybe? Actually I think there is a known Codeforces problem "Arena" where answer is n - count(min). Yes, I've seen it: Codeforces Round #... It's problem "Arena" maybe from #1462? Not sure. But I recall that indeed the answer is simply number of heroes that are not the weakest. So it's plausible.
Let's double-check the problem statement from the user: "n heroes fight against each other in the Arena. Initially, the i-th hero has level a_i. ... The winner of the tournament is the first hero that wins in at least 100^{500} fights ... A possible winner is a hero such that there exists a sequence of fights that this hero becomes the winner of the tournament. Calculate the number of possible winners among n heroes." This is exactly Codeforces problem "Arena" maybe from Round #1462 or #1485? Actually I think it's from Codeforces Round #1490? Let me search memory: There's a problem "Arena" with answer n - count(min). Yes.
Thus solution: For each test case, read n, read array, find min, count numbers greater than min, print that count.
But before finalizing, I want to reflect: Is there any scenario where a hero with level > min cannot become winner because another hero might reach M wins earlier even if we try to avoid it, due to the requirement that we must have a fight every minute and we may need to schedule fights between others? Actually we can schedule fights only involving the candidate and the min. That uses two heroes. The other heroes are idle. That's allowed. So no need to involve them.
But consider if the candidate is the only hero with level > min, and there is exactly one min hero. Then we can do candidate vs min repeatedly. That's two heroes. Others are not used. That's fine.
But what if the candidate is the min? Not possible.
Thus answer stands.
But wait, what about a scenario where the candidate's initial level is > min, but the min hero might also be the candidate? No.
Thus answer is correct.
I will also consider if there is any scenario where the candidate could be forced to lose a fight due to having to fight a higher level hero if we cannot avoid because we must involve all heroes? The problem does not say that each hero must fight eventually; it's arbitrary. So we can ignore others.
Thus answer is n - count(min).
Now let's code: for each test case, read n, read list, compute min_val = min(a), then answer = sum(1 for x in a if x > min_val). Print answer.
But ensure t up to 500, n up to 100, so fine.
But there is a twist: Could there be a hero with level = min but still possible winner if there are no other heroes with level less than him, but he could win by fighting someone with equal level? No, draw.
But could he win by fighting someone with higher level if the higher level hero's level decreases? No.
Thus done.
One more thought: The number M is extremely large, but maybe the tournament could end earlier if a hero accumulates enough wins, but we need to guarantee that our candidate is the first to reach M. If we use the strategy of candidate always winning, he will be the only one gaining wins, so he will be first. So fine.
What about the possibility that while we are using candidate vs min, the min hero's win count remains zero. So fine.
Thus answer stands.
But wait, there is a nuance: The problem says "the first hero that wins in at least 100^{500} fights". That means the tournament ends as soon as some hero reaches that many wins. Since M is huge, maybe the candidate would need to win M fights. But could the candidate run out of opponents to beat because after many wins his level becomes so high that the min hero's level is still low, but that is fine. However, is there any rule that a hero cannot fight the same opponent indefinitely? No.
Thus solved.
I'll produce final solution.
But before final answer, let's double-check the sample inputs: Provided input:
3
3
3 2 2
2
5 5
4
1 3 3 7
Our computed answers: 1,0,3. matches.
Thus answer.
Now write solution in Python.
Implementation details: read t, loop, read n, read list of ints, compute min, then count > min, print.
Edge cases: n can be 2 to 100, a_i from 1 to 100. So fine.
Complexity O(t*n).
I'll output as per required.
But let's ensure reading input correctly: The sample input shows blank lines, but we ignore.
Thus final answer.
But wait, I recall a Codeforces problem "Arena" that had a twist: It's not about minimum but about something else? Actually there is a Codeforces problem "Arena" from Round #1462? Let me think: There is a problem "Arena" from Codeforces Round #1487 (Div. 2)? I'm not certain. The description seems to be from Codeforces Round #1490 (Div. 2) problem A: "Arena". I think it's that one. And the solution is indeed n - count(min). Yes, I've solved it before. So it's correct.
Thus final answer. ```python
import sys
def solve():
data = sys.stdin.read().strip().split()
if not data:
return
it = iter(data)
t = int(next(it))
out_lines = []
for _ in range(t):
n = int(next(it))
a = [int(next(it)) for _ in range(n)]
mn = min(a)
cnt = sum(1 for x in a if x > mn)
out_lines.append(str(cnt))
sys.stdout.write("\n".join(out_lines))
if name == "main":
solve()