#!/usr/bin/env python3 #fileencoding: utf-8 N, M = [int(i) for i in input().strip().split(" ")] A = [int(i) for i in input().strip().split(" ")] c = [i for i in range(1,N+1)] for i in A: c.insert(0,c.pop(i-1)) print(c[0])