#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

map<pair<string, string>, int> m;

int lcsnum(string a, string b)
{
    if (b == "") return 1;
    if (a == "") return 0;
    if (a[a.length()-1] == b[b.length()-1])
    {
        long long x = 0;
        pair<string, string> p;
        p.first = a.substr(0, a.length()-1);
        p.second = b.substr(0, b.length()-1);
        if (m.find(p) != m.end())
        {
            x += m[p]%1000000007;
        }
        else
        {
            m[p] = lcsnum(a.substr(0, a.length()-1), b.substr(0, b.length()-1))%1000000007;
            x += m[p]%1000000007;
        }
        p.first = a.substr(0, a.length()-1);
        p.second = b;
        if (m.find(p) != m.end())
        {
            x += m[p]%1000000007;
        }
        else
        {
            m[p] = lcsnum(a.substr(0, a.length()-1), b)%1000000007;
            x += m[p]%1000000007;
        }
        return x%1000000007;
    }
    else
    {
        long long x = 0;
        pair<string, string> p;
        p.first = a.substr(0, a.length()-1);
        p.second = b;
        if (m.find(p) != m.end())
        {
            x += m[p]%1000000007;
        }
        else
        {
            m[p] = lcsnum(a.substr(0, a.length()-1), b)%1000000007;
            x += m[p]%1000000007;
        }
        return x%1000000007;
    }
}

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    cout << lcsnum(s, s2) << endl;

    return 0;
}