{"extraResources":{"example.01.mu":"TVXzATANCjYNCjEgMiAzIDMgMyA2DQo="},"scoring":null,"notes":"","legend":"\\textit{This is a run-twice problem.}\r\n\r\nA team of $n$ players is sitting around a large round table in a library and playing a cooperative game.\r\nEach player has a card with an integer from $1$ to $n$ glued to their forehead.\r\nPlayers can see each other's numbers but cannot see their own numbers, which they are trying to guess.\r\nSince the game takes place in a library where everyone must be quiet, players make their guesses in writing and simultaneously, without communicating with each other.\r\nThe team wins if at least one player guesses their number correctly.\r\n\r\nYour task is to devise a winning strategy for the team.\r\nThe strategy will be tested in two runs.\r\n\r\nDuring the first run, you will be given the numbers on the cards of all players at the table in clockwise order.\r\nAfter that, you need to select the number of the player who will correctly guess their card.\r\n\r\nDuring the second run, you will be informed of the number of the chosen player, as well as the numbers on the cards that this player can see from their position, from left to right.\r\nIn response, you have to output the number on the chosen player's card.\r\n","authorLogin":"nikgaevoy","language":"english","timeLimit":1000,"output":"During the first run, output a single integer: the number of the player who will correctly guess their card.\r\n\r\nDuring the second run, also output a single integer: the guess of that player.\r\n","inputFile":"stdin","outputFile":"stdout","input":"During both runs, the first line contains a single integer: $0$ if it is the first run, or the number of the player chosen during the first run if it is the second run.\r\n\r\nThe second line contains an integer $n$: the number of players, or the number of cards visible to the player ($n \\leq 2 \\cdot 10^5$).\r\nThe third line contains $n$ integers: the numbers on the cards.\r\n\r\nThere is at least one player at the table.\r\n","authorName":"Nikita Gaevoy","sampleTests":[{"output":"2","input":"0\r\n6\r\n1 2 3 3 3 6\r\n","inputFile":"example.01","outputFile":"example.01.a"},{"output":"2","input":"2\r\n5\r\n3 3 3 6 1","inputFile":"example.02","outputFile":"example.02.a"}],"name":"Who Am I?","interaction":null,"memoryLimit":1073741824,"tutorial":"Let's consider an arbitrary player. In a random test, this player will guess their card with a probability of exactly $1 / n$, where $n$ is the number of players at the table. We need at least one player to guess the answer with a probability of $1$, therefore, in the correct strategy, the answer will be guessed by exactly one player. Thus, the players' strategies must have some parameter that is different for all players and takes exactly $n$ possible values, from which the player can recover their card. The sum of the numbers on all the cards modulo $n$ will serve as such a parameter.\r\n\r\nThus, in the first run, we will choose the player whose number matches the sum of the numbers on all the cards, and in the second run, using this number as the player's number, we will recover the answer."}