public class No_123 { public static void main(String[] args) { java.util.Scanner sc = new java.util.Scanner(System.in); int n = sc.nextInt(); int card[] = new int[n]; for (int i = 1; i <= n; i++) { card[i - 1] = i; } int m = sc.nextInt(); int[] shuffle = new int[m]; for (int i = 0; i < m; i++) { shuffle[i] = sc.nextInt(); } for (int s : shuffle) { int tmp = card[s - 1];// 抜くカードを確保 for (int i = s - 1; i > 0; i--) { card[i] = card[i - 1];// 後ろにコピーしてゆく } card[0] = tmp;// 抜いたカードを一番上に積む } System.out.println(card[0]); sc.close(); } }