#include <iostream>
using namespace std;
const int N = 100010 * 64;
typedef long long ll;
int tr[N];
int lp[N];
int rp[N];
int lastn = 2;
ll getk(int &cur, ll l, ll r, ll k)
{
if (cur == 0) cur = lastn++;
tr[cur]++;
if (l == r)
return l;
ll m = (l + r) / 2;
ll lsize = m - l + 1 - tr[lp[cur]];
if (lsize >= k)
return getk(lp[cur], l, m, k);
else
return getk(rp[cur], m + 1, r, k - lsize);
}
int root = 1;
int main()
{
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
ll p = 0;
for (int i = 0; i < k; ++i){
ll x;
cin >> x;
p = (p + x - 1) % (n - i) + 1;
ll res = getk(root, 1, n, p);
cout << res << ' ';
--p;
}
cout << '\n';
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgTiA9IDEwMDAxMCAqIDY0Owp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKaW50IHRyW05dOwppbnQgbHBbTl07CmludCBycFtOXTsKaW50IGxhc3RuID0gMjsKbGwgZ2V0ayhpbnQgJmN1ciwgbGwgbCwgbGwgciwgbGwgaykKewoJaWYgKGN1ciA9PSAwKSBjdXIgPSBsYXN0bisrOwoJdHJbY3VyXSsrOwoJaWYgKGwgPT0gcikKCQlyZXR1cm4gbDsKCWxsIG0gPSAobCArIHIpIC8gMjsKCWxsIGxzaXplID0gbSAtIGwgKyAxIC0gdHJbbHBbY3VyXV07CglpZiAobHNpemUgPj0gaykKCQlyZXR1cm4gZ2V0ayhscFtjdXJdLCBsLCBtLCBrKTsKCWVsc2UKCQlyZXR1cm4gZ2V0ayhycFtjdXJdLCBtICsgMSwgciwgayAtIGxzaXplKTsKfQppbnQgcm9vdCA9IDE7CmludCBtYWluKCkKewoJaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwoJbGwgbiwgazsKCWNpbiA+PiBuID4+IGs7CglsbCBwID0gMDsKCWZvciAoaW50IGkgPSAwOyBpIDwgazsgKytpKXsKCQlsbCB4OwoJCWNpbiA+PiB4OwoJCXAgPSAocCArIHggLSAxKSAlIChuIC0gaSkgKyAxOwoJCWxsIHJlcyA9IGdldGsocm9vdCwgMSwgbiwgcCk7CgkJY291dCA8PCByZXMgPDwgJyAnOwoJCS0tcDsKCX0KCWNvdXQgPDwgJ1xuJzsKCXJldHVybiAwOwp9