func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5e3 + 7;   long long M = 1e9 + 7;   long long dp[N];   long long g[N][30];   int n;   vector<int> a;   int ch[N][N];   int main() {     ch[0][0] = 1;     cin >> n;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= i; j++) {         if (j == 0) {           ch[j][i] = 1;           continue;         }         ch[j][i] = (ch[j - 1][i - 1] + ch[j][i - 1]) % M;       }     }     for (int i = 1; i <= n; i++) {       char c;       cin >> c;       if (!a.size())         a.push_back(c -  a  + 1);       else if (a.back() != c -  a  + 1)         a.push_back(c -  a  + 1);     }     dp[0] = 1;     for (int i = 0; i < a.size(); i++) {       for (int j = a.size(); j >= 2; j--) {         dp[j] += -g[j][a[i]] - g[j - 1][a[i]] + dp[j - 1];         g[j][a[i]] = dp[j - 1] - g[j - 1][a[i]];         dp[j] %= M;         g[j][a[i]] %= M;       }       if (g[1][a[i]] == 0) dp[1]++;       g[1][a[i]] = 1;     }     long long res = 0;     for (int i = 1; i <= n; i++) {       dp[i] = (((dp[i] % M) + M) % M);       res = (res + ch[i - 1][n - 1] * dp[i]) % M;     }     cout << res;     return 0;   }   