#include <iostream>
#include <string>
#include <map>

int main(){
    int N;
    std::map<char, long int> AZBUKA;
    std::map<char, long int> ponovljeni;
    std::cin >> N;
    
    long int mod = 1000000007;
    
    char c;
    char c_last;
    for(int i = 0 ; i < N ; i++){
        std::cin >> c;
        if(c != c_last && AZBUKA[c] != 0){
            ponovljeni[c]++;
        }
        else if(c==c_last && AZBUKA[c] != 0 && ponovljeni[c] != 0)
        {
            ponovljeni[c]++;
        }
        else {
            AZBUKA[c]++;
        }
        c_last = c;
    }
    long int koef = 1;
  for(auto x : AZBUKA){
      if(ponovljeni[x.first] > 0)
        koef = koef * x.second;
    else{
        if(x.second > 2)
        koef = koef * ((x.second * (x.second - 1)) / 2);
        else
        koef = koef * x.second;
    }
   }
   
/*   for(auto x : AZBUKA){
       std::cout << x.first << " " << x.second << std::endl;
   }
   */
   std::cout << koef % mod;
   return 0;
}