using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { string s1 = Console.ReadLine(); string[] t1 = s1.Split(' '); string s2 = Console.ReadLine(); string[] t2 = s2.Split(' '); int cardnum = int.Parse(t1[0]); int shufflenum = int.Parse(t1[1]); int[] stacknum = new int[100000]; int[] datanum = new int[100000]; for (int i = 0; i < shufflenum; i++) { stacknum[i] = int.Parse(t2[i]); } for (int i = 0; i < cardnum; i++) { datanum[i] = i + 1; } for (int i = 0; i < shufflenum; i++) { int kari = datanum[stacknum[i] - 1]; int temp = datanum[0]; int temp2 = 0; for (int j = 0; j < stacknum[i] - 1; j++, temp = temp2) { temp2 = datanum[j + 1]; datanum[j + 1] = temp; } datanum[0] = kari; } Console.WriteLine(datanum[0]); } } }