#include <iostream>
#include <queue>

using namespace std;

void solve()
{
	int n;
	while(cin >> n)
	{
		int r;
		cin >> r;
		queue<int> deckA, deckB, deckC;
		for(int i = 0; i < n; ++i)
		{
			deckC.push(i);
		}
		while(r--)
		{
			int c;
			cin >> c;
			if(n % 2)
			{
				for(int i = 0; i < n / 2; ++i)
				{
					deckB.push(deckC.front());
					deckC.pop();
				}
				for(int i = 0; i < n / 2 + 1; ++i)
				{
					deckA.push(deckC.front());
					deckC.pop();
				}
			}
			else
			{
				for(int i = 0; i < n / 2; ++i)
				{
					deckB.push(deckC.front());
					deckC.pop();
				}
				for(int i = 0; i < n / 2; ++i)
				{
					deckA.push(deckC.front());
					deckC.pop();
				}
			}
			while(!deckA.empty())
			{
				for(int i = 0; i < c; ++i)
				{
					if(deckA.empty())
					{
						break;
					}
					deckC.push(deckA.front());
					deckA.pop();
				}
				for(int i = 0; i < c; ++i)
				{
					if(deckB.empty())
					{
						break;
					}
					deckC.push(deckB.front());
					deckB.pop();
				}
			}
		}
		cout << deckC.back() << endl;
	}
}

int main()
{
	solve();
	return(0);
}