import java.util.*; public class card{ public static void main(String... args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); ArrayList list = new ArrayList(); for(int i = 1; i <= n; i++){ list.add(i); } int[] shuffle = new int[m]; for(int i = 0; i < m; i++){ shuffle[i] = scan.nextInt(); } System.out.println(cardShuffle(list,shuffle)); } public static int cardShuffle(ArrayList list,int[] shuffle){ for(int i = 0;i < shuffle.length; i++){ int now = list.get(shuffle[i]); list.remove(shuffle[i]); list.add(0,now); } return list.get(0); } }