#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vector<int> cards;
int n,r;

void f(int t){
	vector<int> a,b,c;
	int i;
	for(i=0;i<n;i++){
		if(i>=n/2)a.push_back(cards[i]);
		else b.push_back(cards[i]);
	}
	int j;
	for(i=0;i<n;i+=t){
		for(j=0;j<t&&i+j<a.size();j++){
			c.push_back(a[i+j]);
		}
		for(j=0;j<t&&i+j<b.size();j++){
			c.push_back(b[i+j]);
		}
	}
	cards=c;
}

int main() {
	while(cin>>n>>r){
		cards.clear();
		int i;
		for(i=0;i<n;i++){
			cards.push_back(i);
		}
//int j;
//for(j=0;j<n;j++){
//cout<<cards[j];
//}
//cout<<endl;
		for(i=0;i<r;i++){
			f(in());
//int j;
//for(j=0;j<n;j++){
//cout<<cards[j];
//}
//cout<<endl;
		}
		cout<<cards[n-1]<<endl;
	}
	return 0;
}