#include using namespace std; using ll = long long; const ll mod = 1e9 + 7; const int N = 200005; const int INF = 0x3f3f3f3f; int a[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int mx = 0; for (int i = 0; i < n; i++) { cin >> a[i]; mx = max(mx, a[i]); } int k = __lg(mx) + 1; int max1 = (1 << k) - 1; ll ans = 0; int u = 0; for (int mask = 0; mask <= max1; mask++) { ll m1 = 0, m2 = 0; bool ok = 1; for (int i = 0; i < n; i++) { bool fw = !(a[i] & (max1 ^ mask)); bool fb = !(a[i] & mask); if (!fw && !fb) { ok = 0; break; } if (fw) { m1 |= a[i]; } else { m2 |= a[i]; } } if (!ok) continue; if (m1 * m2 > ans) { ans = m1 * m2; u = mask; } } string res; ll m1 = 0, m2 = 0; for (int i = 0; i < n; i++) { bool fw = !(a[i] & (max1 ^ u)); if (fw) { res.push_back('B'); m1 |= a[i]; } else { res.push_back('W'); m2 |= a[i]; } } cout << ans << "\n"; cout << res << "\n"; return 0; }