#include <bits/stdc++.h>

int riffleShuffle(const int &n, const int &r) {
    std::queue<int> deckA, deckB, deckC;

    for (int i = 0; i < n/2; i++) deckB.push(i);
    for (int i = n/2; i < n; i++) deckA.push(i);

    int c;

    for (int t = 0; t < r; t++) {

        if (t > 0) {
            for (int i = 0; i < n/2; i++) {
                deckB.push(deckC.front());
                deckC.pop();
            }
            for (int i = n/2; i < n; i++) {
                deckA.push(deckC.front());
                deckC.pop();
            }
        }

        std::scanf("%d", &c);
        int cnt = 0;

        while (!deckA.empty() || !deckB.empty()) {
            for (int i = 0; i < c && !deckA.empty(); i++) {
                deckC.push(deckA.front());
                deckA.pop();
            }
            for (int i = 0; i < c && !deckB.empty(); i++) {
                deckC.push(deckB.front());
                deckB.pop();
            }
        }
    }
    return deckC.back();

}

int main() {

    int n, r;
    while (scanf("%d %d",&n, &r)!=EOF) {
        std::cout << riffleShuffle(n, r) << std::endl;
    }
    return 0;
}

