#include using namespace std; struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define vv(type, c, m, n, i) vector> c(m, vector(n, i)) #define rep(i,a,n) for(int i=(a), i##_len=(n); ii##_len; --i) #define len(x) ((int)(x).size()) #define mp make_pair #define eb emplace_back #define em emplace #define fi first #define se second #define get(a, i) get(a) #define mt make_tuple #define mine min_element #define maxe max_element #define sum(a, b) accumulate(a, b) #define chmax(a,b) if(ab)a=b #define print(t) cout << (t) << "\n"; #define printk(v) rep(i, 0, len(v) - 1) { cout << v[i] << " "; } cout << v.back() << endl; typedef long long ll; typedef long double ld; typedef vector vi; typedef vector vd; typedef vector vll; typedef vector vs; typedef vector vb; typedef pair pii; const constexpr ll mod = 1000000007; int main() { string s = string("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); map mci; map mic; int k = 0; for (char c: s) { mci[c] = k; mic[k++] = c; } int n, m; cin >> n >> m; string card = s.substr(1, n); int a; rep(i, 0, m) { cin >> a; --a; card = card[a] + card.substr(0, a) + card.substr(a + 1, n); } print(mci[card[0]]); return 0; }