Vinnytsia Programmers' Amusements
In recent years, Vinnytsia has gained fame as one of Ukraine's most notable cities, largely due to its stunning fountains. Tourists from across the country, and occasionally from abroad, visit to witness this breathtaking spectacle.
However, not many are aware that Vinnytsia holds a special place in the programming community. For instance, it hosts the annual NET-OI, a remote programming olympiad for schoolchildren. For two decades, it has also been the venue for the "Tournament of Champions," a comprehensive olympiad for the winners and runners-up of the All-Ukrainian school olympiads in mathematics, physics, and computer science. Additionally, in recent years, Vinnytsia has hosted the ACM Ukraine student final, which serves as a semifinal for the world student programming team championship.
It's only natural that programmers, when gathered, would blend business with pleasure and come up with something unique. Indeed, during such events, programmers often organize tours to another Vinnytsia highlight—the Roshen chocolate factory. At the end of these tours, prizes provided by the confectionery manufacturers are raffled off in an exciting fashion.
On a table, N cups are arranged in a circle, each initially containing one candy. K numbered programmer-tourists (referred to as players) stand by one of the cups. Each player then selects a number from 1 to N−1. Players take turns, and during a turn, a player moves clockwise around the table, counting the cups until they have passed the number of cups they initially chose. They then take a candy (if available) from the cup where they stop. The game concludes when all the cups are empty, after which players enjoy the candies they've collected.
Your task is to write a program that assists the K-th programmer-player, who chooses their number last, in selecting a number that maximizes their candy collection. While they could determine this themselves, they are currently preoccupied with enjoying sweets.
Input
The first line of the input contains two integers separated by a space: the number of cups N and the number of participants K (1 ≤ K < N < 100, with N being a prime number). The second line contains (K−1) integers ranging from 1 to (N−1), separated by spaces, representing the numbers chosen by players numbered from 1 to (K−1).
Output
Output a single integer from 1 to (N−1) on the first line—the number that allows the K-th player to collect the maximum number of candies. If multiple numbers yield the same maximum, print the smallest one.