import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int M = scan.nextInt(); int []A = new int[M]; ArrayList list = new ArrayList(); for(int i = 0; i < M; i++) { A[i] = scan.nextInt(); } scan.close(); for(int i = 0; i < N; i++) { list.add(i + 1); } for(int i = 0; i < M; i++) { int temp = list.get(A[i] - 1); list.remove(A[i] - 1); list.add(M - 1, temp); } System.out.println(list.get(0)); } }