import java.util.LinkedList; import java.util.Scanner; public class No_123second { public static void main(String[] args) { Scanner sc = new Scanner(System.in); LinkedList card = new LinkedList(); int n = sc.nextInt(); int m = sc.nextInt(); int[] shuffle = new int[m]; for (int i = 1; i <= n; i++) { card.add(i); } for (int i = 0; i < m; i++) { shuffle[i] = sc.nextInt(); } for (int s : shuffle) { int i = card.remove(s - 1); card.offerFirst(i); } System.out.println(card.peek()); sc.close(); } }