#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<string.h>
using namespace std;
long long int a[300001];
long long int b[300001];
long long int amax[200001];
string func0(string s);
string func1(string s);
string func2(string s);
int main() {
	
	int n;
	cin >> n;
	int bi[9] = { 1,2,4,8,16,32,64,128,256 };
	cout << bi[n] - 1 << endl;

	string ab[256], abold[256];

	int i, j;
	ab[0] = "AB";

	for (i = 2; i <= n; i++) {
		for (j = 0; j < 256; j++) {
			abold[j] = ab[j];
		}
		ab[0] = func0(abold[0]);
		for (j = 0; j < bi[i - 1] - 1; j++) {
			ab[j+1] = func1(abold[j]);
		}
		for (j = 0; j < bi[i - 1]-1; j++) {
			ab[j + bi[i - 1]] = func2(abold[j]);
		}
	}


	
	for (i = 0; i < bi[n]-1; i++) {
		cout << ab[i] << endl;
	}
	return 0;



}

string func0(string s) {
	return s + s;
}
string func1(string s) {
	int i;
	string t = "";
	for (i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			t = t + "AA";
		}
		else if(s[i] == 'B') {
			t = t + "BB";
		}
	}
	return t;
}
string func2(string s) {

	int i;
	string t = "";
	for (i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			t = t + "AB";
		}
		else if (s[i] == 'B') {
			t = t + "BA";
		}
	}
	return t;

}
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
template <class T>
vector<T> Vec(int64_t a, int64_t x = 0) {
    return vector<T>(a, x);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    ll n;
    cin >> n;
    auto a = Vec<ll>(n);
    rep(i, n) cin >> a[i];
    rep(i, n - 1) a[i + 1] += a[i];

    ll ans = 0, p = 0, max = 0;
    rep(i, n) {
        chmax(ans, p + max);
        p += a[i];
        chmax(ans, p);
        chmax(max, a[i]);
    }
    co(ans);

    return 0;
}