#include "bits/stdc++.h" #ifdef WINT_MIN #define __MAI #endif using namespace std; typedef unsigned int uint; typedef long long int ll; typedef unsigned long long int ull; #define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout< ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<>= 1, k++)s = (s << 1) | (u & 1); for (; 0>= 1)cout << (s & 1); } }template ostream& operator <<(ostream &o, const pair p) { o << "(" << p.first << ":" << p.second << ")"; return o; } #define TIME chrono::system_clock::now() #define MILLISEC(t) (chrono::duration_cast(t).count()) namespace { std::chrono::system_clock::time_point t; void tic() { t = TIME; } void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - t)); } std::chrono::system_clock::time_point tle = TIME; #ifdef __MAI void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); } #else #define safe_tle(k) ; #endif } #ifndef __MAI namespace { class MaiScanner { public: template void input_integer(T& var) { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc<'0' || '9'>(int& var) { input_integer(var); return *this; } MaiScanner& operator>>(long long& var) { input_integer(var); return *this; } }; } MaiScanner scanner; #else #define scanner cin #endif // ---------------------------------------------- // 個人的な便利ツールここまで // ---------------------------------------------- inline int compare(int l, int r) { return l > r; } #define A_SAN 1 #define B_SAN 0 int n; // 実装内容の説明は #165951 を確認してください. map, int> dp; int solve(vector cc) { sort(cc.begin(), cc.end() - 1, compare); auto dp_ref = dp.find(cc); if (dp_ref != dp.end()) return dp_ref->second; int turn = cc[n]; cc[n] = !turn; for (int i = 0; i < n - 1 && cc[i] ; ++i) { --cc[i]; if (solve(cc) == turn) { ++cc[i]; cc[n] = turn; return dp[cc] = turn; } if (turn == B_SAN && cc[i]) { --cc[i]; if (solve(cc) == turn) { cc[i] += 2; cc[n] = turn; return dp[cc] = turn; } ++cc[i]; } ++cc[i]; } return dp[cc] = !turn; } int main() { int a; scanner >> n; vector cc(n + 1); repeat(n) { scanner >> a; cc[cnt] = min(3, a); } sort(ALL(cc), compare); cc[n] = A_SAN; cout << (solve(cc) ? "A" : "B") << endl; return 0; }