// Aizu Vol-10 1017: Riffle Shuffle
// 2017.8.24 bal4u@uu

#include <stdio.h>

int a[55], b[55], c[55];
int ca, cb, ia, ib, ic;

int main()
{
	int n, r, m, k;

	while (scanf("%d%d", &n, &r) == 2) {
		for (k = 0; k < n; k++) c[k] = k;
		cb = n >> 1, ca = n - cb;
		while (r-- > 0) {
			k = 0;
			for (ib = 0; ib < cb; ib++) b[ib] = c[k++];
			for (ia = 0; ia < ca; ia++) a[ia] = c[k++];
			scanf("%d", &m);
			for (ia = ib = ic = 0; ia < ca || ib < cb; ) {
				for (k = 0; k < m && ia < ca; k++) c[ic++] = a[ia++];
				for (k = 0; k < m && ib < cb; k++) c[ic++] = b[ib++];
			}
		}
		printf("%d\n", c[ic-1]);
	}
	return 0;
}