#include <iostream>

using namespace std;
char c[4];
typedef long long ll;
ll mod = 1000000007;
ll pw(ll a, ll x){
    if(x<0) return 1;
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= mod;
        (a *= a) %= mod; x /= 2;
    }
    return ret;
}

ll dp1[2010][2],dp2[2010][2];
void solve(){
    dp1[0][0] = 1,dp2[0][0] = 1;
    int i,n = 1010;
    for(i=1;i<=n;i++){
        (dp1[i][0] += dp1[i - 1][1]) %= mod;
        (dp1[i][1] += dp1[i - 1][0] + dp1[i - 1][1]) %= mod;
        (dp2[i][0] += dp2[i - 1][0] + dp2[i - 1][1]) %= mod;
        (dp2[i][1] += dp2[i - 1][0]) %= mod;
    }
}

int main(){
    int i,n; cin >> n;
    for(i=0;i<4;i++) cin >> c[i];
    solve();
    if(c[1]=='A'){
        if(c[0]=='A'){
            cout << 1 << endl;
        }else{
            if(c[0]==c[1]){
                if(n>=3) cout << pw(2,n - 3) << endl;
                else cout << 1 << endl;
            }else{
                if(c[0]=='B' && c[2]=='B') cout << pw(2,n - 3) << endl;
                else cout << dp2[n - 1][1] << endl;
            }
        }
    }else{
        if(c[3]=='B'){
            cout << 1 << endl;
        }else{
            if(c[2]==c[3]){
                if(n>=3) cout << pw(2,n - 3) << endl;
                else cout << 1 << endl;
            }else{
                if(c[2]=='A' && c[3]=='A') cout << pw(2,n - 3) << endl;
                else cout << dp1[n - 1][1] << endl;
            }
        }
    }
}
#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> sumVec(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> A.at(i);
        if (i == 0)
        {
            sumVec.at(i) = A.at(i);
        }
        else
        {
            sumVec.at(i) = sumVec.at(i - 1) + A.at(i);
        }
    }
    // 1+2 + 2+1+2
    // 1+max, 2+1+max,3+2+1+max

    // 2 1 1 3
    // 1 + 4 + 4
    long long maxValue = 0;
    long long addedMaxValue = 0;
    long long sum = 0;
    long long sumsums = 0;
    for (long long i = 0; i < A.size(); i++)
    {
        sumsums += sumVec.at(i);
        if (maxValue < A.at(i))
        {
            maxValue = A.at(i);
        }
        auto sum = sumsums + maxValue * (i + 1);
        cout << sum << endl;
    }
}