using System; using System.Collections.Generic; public class Program { static void Main() { string s = Console.ReadLine(); string[] t = s.Split(' '); // カード枚数 int N = Int32.Parse(t[0]); // 全カード情報生成 List cardList = new List(); for(int i = 0; i < N; i++)cardList.Add(i+1); // シャッフル情報取得 s = Console.ReadLine(); string[] shArrayString = s.Split(' '); // シャッフル実行 int shIndex; int shOldValue; for(int i = 0; i < shArrayString.Length; i++) { shIndex = Int32.Parse(shArrayString[i]) - 1; shOldValue = cardList[shIndex]; cardList.RemoveAt(shIndex); cardList.Insert(0,shOldValue); } Console.WriteLine($"{cardList[0]}"); } }