using System; using System.Collections.Generic; using System.Linq; namespace Test { class Program { static void Main(string[] args) { int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); LinkedList card = new LinkedList(); for (int i = 1; i <= x[0]; i++) card.AddLast(i); for (int i = 0; i < x[1]; i++) { int n = card.First.Value; for (int j = 0; j < a[i] - 1; j++) { n = card.Find(n).Next.Value; } card.Remove(n); card.AddFirst(n); } Console.WriteLine(card.First.Value); } } }