//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pb push_back
#define F first
#define S second
//#pragma GCC optimize("Ofast")

const int maxn = 1000 + 5;

int n;
string s[maxn][2];

string inv(string ss)
{
	for(int i = 0; i < ss.size(); i++)
		ss[i] = (ss[i] == 'A' ? 'B' : 'A');
	return ss;
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	s[0][0] = "AB";
	int last = 1;
	for(int i = 1; i < n; i++)
	{
		//cout << "BOOM\n";
		for(int j = 0; j < last; j++)
			s[j][i % 2] = s[j][(i + 1) % 2] + s[j][(i + 1) % 2];//, cout << j << " " << s[j][i % 2] << '\n';
		for(int j = last; j < 2 * last; j++)
			s[j][i % 2] = s[j - last][(i + 1) % 2] + inv(s[j - last][(i + 1) % 2]);//, cout << j << " " << s[j][i % 2] << '\n';
		
		s[2 * last][i % 2] = "";
		for(int j = 0; j < (1 << i); j++)
			s[2 * last][i % 2].pb('A');
		for(int j = 0; j < (1 << i); j++)
			s[2 * last][i % 2].pb('B');
		last = 2 * last + 1;
	}
	//return 0;
	cout << last << '\n';
	for(int i = 0; i < last; i++)
		cout << s[i][(n - 1) % 2] << '\n';
	//cout << (n - 1) % 2 << '\n';
}

#include <bits/stdc++.h>
#include <unordered_set>
#include <cmath>
#include <algorithm>
// #include <atcoder/all>

// URL: 

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vs = vector<string>;

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n)? "YES": "NO") << endl
#define Yes(n) cout << ((n)? "Yes": "No") << endl

#define rept(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fore(x, a) for(auto& (x) : (a))

#define reptll(i, a, b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define repll(i, n) for (ll i = 0; i < (ll)(n); i++)

#define ALL(a) (a).begin(), (a).end()

#define VECCIN(x) for(auto& youso_: (x)) cin >> youso_
#define VECCOUT(x) for(auto& youso_: (x)) cout << youso_ << " ";cout << endl

#define pb push_back
#define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INFL = numeric_limits<ll>::max() / 4;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  optimize_cin();

  ll N;
  cin >> N;

  vll A(N);
  vll C(N + 1);
  map<ll, ll> D;

  C[0] = 0;
  rep(i, N){
    cin >> A[i];
    C[i + 1] = C[i] + (i % 2 == 0? A[i] : - A[i] ); 
  }

  ll cnt = 0;
  rep(i, N + 1) {
    cnt += D[C[i]];
    D[C[i]]++;
  }

  cout << cnt << endl;

  return 0;
}