#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1010000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}


char ff(char s, char t){
    if(s == t) return t;
    if(s != 'R' && t != 'R') return 'R';
    else if(s != 'B' && t != 'B') return 'B';
    else return 'W';
}

string g(string s){
    //cout << 1 csp si(s) csp s << endl;
    
    if(si(s) == 1) return s;
    
    int a = 1;
    int aa = a;
    while (a <= si(s)) {
        if((si(s)-1) % a == 0) chmax(aa,a);
        a *= 3;
    }
    
    string t = "";
    int b = 0;
    while (b+aa < si(s)) {
        t += ff(s[b],s[b+aa]);
        //cout << s[b] csp b csp s[b+aa] csp b+aa << " ";
        b += aa;
    }
    //cout << endl;
    if(si(t) == 1) return t;
    else return g(t);
}



int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    string s;
    cin >> s;
    
    cout << g(s) << endl;
    
    

    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;

class Mint {
private:
	int val;

public:
	Mint () {val = 0;}

	Mint(int _val) : val(_val) {}

	Mint& operator += (const Mint &o) {val = (val + o.val < mod ? val + o.val : val + o.val - mod); return *this;}
	template <typename T> Mint& operator += (const T &o) {return *this += Mint(o);} 

	Mint& operator -= (const Mint &o) {val = (val < o.val ? val - o.val + mod : val - o.val); return *this;}
	template <typename T> Mint& operator -= (const T &o) {return *this -= Mint(o);} 

	Mint& operator *= (const Mint &o) {return *this = (1LL * val * o.val >= mod ? (1LL * val * o.val) % mod : val * o.val);}
	template <typename T> Mint& operator *= (const T &o) {return *this *= Mint(o);} 

	friend bool operator == (const Mint &o1, const Mint &o2) {return (o1.val == o2.val);}
	template <typename T> friend bool operator == (const Mint &o1, const T &o2) {return (o1 == Mint(o2));}
	template <typename T> friend bool operator == (const T &o1, const Mint &o2) {return (Mint(o1) == o2);}

	friend bool operator != (const Mint &o1, const Mint &o2) {return (o1.val != o2.val);}
	template <typename T> friend bool operator != (const Mint &o1, const T &o2) {return (o1 != Mint(o2));}
	template <typename T> friend bool operator != (const T &o1, const Mint &o2) {return (Mint(o1) != o2);}

	friend Mint operator + (const Mint &o1, const Mint &o2) {return Mint(o1) += o2;}
	template <typename T> friend Mint operator + (const Mint &o1, const T &o2) {return Mint(o1) += o2;}
	template <typename T> friend Mint operator + (const T &o1, const Mint &o2) {return Mint(o1) += o2;}

	friend Mint operator - (const Mint &o1, const Mint &o2) {return Mint(o1) -= o2;}
	template <typename T> friend Mint operator - (const Mint &o1, const T &o2) {return Mint(o1) -= o2;}
	template <typename T> friend Mint operator - (const T &o1, const Mint &o2) {return Mint(o1) -= o2;}

	friend Mint operator * (const Mint &o1, const Mint &o2) {return Mint(o1) *= o2;}
	template <typename T> friend Mint operator * (const Mint &o1, const T &o2) {return Mint(o1) *= o2;}
	template <typename T> friend Mint operator * (const T &o1, const Mint &o2) {return Mint(o1) *= o2;}

	Mint power(long long y) {
		Mint ans = 1;
		Mint x = *this;

		while(y > 0) {
			if(y & 1) ans *= x;
			y >>= 1;
			x *= x;
		} 
		return ans;
	}

	Mint inverse () {return power(mod - 2);}

	Mint& operator /= (const Mint &o) {return *this *= Mint(o).inverse();}
	template <typename T> Mint& operator /= (const T &o) {return *this *= Mint(o).inverse();} 

	friend Mint operator / (const Mint &o1, const Mint &o2) {return Mint(o1) /= o2;}
	template <typename T> friend Mint operator / (const Mint &o1, const T &o2) {return Mint(o1) /= o2;}
	template <typename T> friend Mint operator / (const T &o1, const Mint &o2) {return Mint(o1) /= o2;}

	bool operator ~ () const {return ~(this -> val);}
	bool operator ! () const {return (this -> val == 0);}
	void operator ++ () {*this += 1;}
	void operator -- () {*this -= 1;} 
	void operator ++ (int) {*this += 1;}
	void operator -- (int) {*this -= 1;}

	friend ostream &operator << (ostream &os, const Mint &o) {os << o.val; return os;}
};

const int maxN = 3005;
Mint dp[maxN][maxN], mp[maxN][maxN];

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;

	ll a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}

	mp[0][0] = 1;

	ll sum = 0;
	for(int i = 1; i <= n; i++) {
		sum += a[i - 1];
		for(int j = i; j > 0; j--) {
			dp[i][j] = mp[j - 1][sum % j];
			mp[j][sum % (j + 1)] += dp[i][j];
		}
	}

	Mint ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += dp[n][i];
	}
	cout << ans;
}
