import java.util.Scanner; import java.util.ArrayList; public class yukicoder_123 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); int m = stdIn.nextInt(); int[] a = new int[m]; for (int i = 0; i < m; i++) { a[i] = stdIn.nextInt(); } ArrayList list = new ArrayList(50); for (int i = 1; i <= n; i++) { list.add(i); } for (int i = 0; i < m; i++) { Integer x = list.get(a[i] - 1); list.remove(a[i] - 1); list.add(0, x); } System.out.println(list.get(0)); } }