#!/usr/bin/python # -*- coding: utf-8 -*- N,M = map(int, raw_input().split()) arys = map(int, raw_input().split()) ans = [] for i in xrange(1,N+1): ans.append(int(i)) for i in arys: tmp = ans.pop(i-1) ans.insert(0,tmp) print ans[0]