#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const ll INF = 1LL << 50;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)

void riffle(vector<int> &nums, int c){
	int n = nums.size();
	vector<int> B(nums.begin(), nums.begin() + n/2), A(nums.begin()+n/2, nums.end()), C;
	int pa = 0, pb = 0;
	while((int)C.size() < n){
		for(int i = 0; i < c && pa < (int)A.size(); i++){
			C.push_back(A[pa++]);
		}
		for(int i = 0; i < c && pb < (int)B.size(); i++){
			C.push_back(B[pb++]);
		}
	}
	nums = C;
}

int main(){
	int n, r, c;
	while(cin >> n >> r &&(n || r)){
		vector<int> nums;
		rep(i, n) nums.push_back(i);
		rep(i, r){
			cin >> c;
			riffle(nums, c);
		}
		cout << nums[n-1] << endl;
	}
	return 0;
}