#include <iostream>
#include <deque>
using namespace std;
int main() {
	// your code goes here
	int n,r,c;
	while(cin >> n>>r){
		deque<int> A,B,C;
		for(int i=0;i<n;i++)
		C.push_back(i);
		for(int i=0;i<r;i++){
			cin >>c;
			for(int i=0;i<n/2;i++)
				B.push_back(C[i]);
			for(int i=n/2;i<n;i++)
				A.push_back(C[i]);
			C.clear();
			while(!(A.empty()&&B.empty())){
				for(int i=0;i<c &&(!A.empty());i++){
					C.push_back(A.front());
					A.pop_front();
				}	
				for(int i=0;i<c &&(!B.empty());i++){
					C.push_back(B.front());
					B.pop_front();
				}
			}
		}
		cout << C.back() << endl;
	}
	return 0;
}