#include <bits/stdc++.h>
using namespace std;
int dfs(int u, int v, int index, vector<int>& dp, vector<char>& ans,
        unordered_map<int, int>& m, int n, vector<int>& arr) {
  if (dp[u] != -1) {
    return dp[u] + 1;
  }
  int p = 0;
  for (int i = index + u; i <= n; i = i + u) {
    if (arr[i] > u) {
      p = dfs(arr[i], v, m[arr[i]], dp, ans, m, n, arr);
      if (p % 2 != 0) {
        break;
      }
    }
  }
  if (p % 2 == 0) {
    for (int i = index - u; i >= 0; i = i - u) {
      if (arr[i] > u) {
        p = dfs(arr[i], v, m[arr[i]], dp, ans, m, n, arr);
        if (p % 2 != 0) {
          break;
        }
      }
    }
  }
  if (p % 2 == 0) {
    ans[u] = 'B';
  } else {
    ans[u] = 'A';
  }
  dp[u] = p;
  return dp[u] + 1;
}
void solution() {
  int n;
  cin >> n;
  unordered_map<int, int> m;
  vector<int> arr(n + 1, -1);
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    m[a] = i;
    arr[i] = a;
  }
  vector<int> dp(n + 1, -1);
  vector<char> ans(n + 1, 'C');
  for (int i = 1; i <= n; i++) {
    if (dp[i] == -1) {
      int a = dfs(i, i + 1, m[i], dp, ans, m, n, arr);
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[arr[i]];
  }
  cout << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solution();
  }
  return 0;
}
