Staring Contest

시간 제한1초메모리 제한1024 MB

문제

A staring contest is a classical battle of imperturbability in which two people stare into each other's eyes while maintaining a facial expression of assured serenity. The goal is to maintain eye contact for longer than your opponent. The contest ends when one participant breaks composure, typically by looking away, smiling, speaking, or giggling.

As a coach of the national staring contest you need to determine the imperturbability of each of your team's $n$ members for the upcoming world finals. The $i$th athlete can maintain eye contact for exactly $a_i$ seconds, but these values are unknown to you in the beginning. For instance, you could have a team of $n=3$ members:

$i$Name$a_i$
1Anna431
2Esther623
3Tony121

When athletes $i$ and $j$ compete, the confrontation lasts exactly $\min(a_i, a_j)$ seconds, at which moment the weaker contestant breaks composure and both contestants start smiling and giggling within a fraction of a second. For instance, if Anna competes against Esther, the contest lasts for $431$ seconds. Importantly, to an outside observer the actual winner of the confrontation (in this case, Esther) is impossible to determine, only the duration of the contest is measurable.

Your goal is to estimate the values $a_1,\ldots, a_n$ using as few staring contests as possible. Clearly, the strength of the strongest athlete can never be determined, so you are allowed to underestimate one of the $a_i$.

제한

The number $n$ of athletes satisfies $2\leq n\leq 1500$. The imperturbability $a_i$ of each athlete satisfies $1\leq a_i\leq 86\,400$, they are all different. You can use at most $3000$ queries; your final line of output, i.e., the line starting with !, is not counted as a query.