#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
typedef unsigned long long ull;
#define vvi std::vector<std::vector<int> >
#define vvs std::vector<std::vector<string> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;
int main(int argc, char const *argv[]) {
  int N;
  ll ans = 0;
  string s, S, t, T="";
  std::cin >> N;
  std::cin >> s;
  S = s.substr(0, N);
  t = s.substr(N);
  for(int i=0;i<N;i++) T+=t[N-1-i];
  std::vector<int> num(26, 0);
  for(int i=0;i<N;i++) num[S[i]-'a']++, num[T[i]-'a']--;
  bool flag = true;
  for(int i=0;i<26;i++) if(num[i]!=0) flag = false;
  vvs str = vv(0, 2, "", string);
  for(int i=0;i<(1<<N);i++){
    int n = i+(1<<20), count=0;
    string ah = "", bh = "";
    while(count<N){
      if(n%2==1) ah += T[count];
      if(n%2==0) bh += T[count];
      count++;
      n/=2;
    }
    str.push_back(std::vector<string> {ah, bh});
  }
  sort(str.begin(), str.end());
  for(int i=0;i<(1<<N);i++){
    int n = i + (1<<20), count=0;
    string ah="", bh="";
    while(count<N){
      if(n%2==1) ah += S[count];
      if(n%2==0) bh += S[count];
      count++;
      n/=2;
    }
    int k = upper_bound(str.begin(), str.end(), std::vector<string> {ah,bh}) - lower_bound(str.begin(), str.end(), std::vector<string> {ah, bh});
    ans += k;
  }
  std::cout << (!flag?0:ans) << '\n';
  return 0;
}

#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[110000] = {}, DP2[110000] = {};

long long int pow_m1(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

int main(){
	long long int N, X;
	cin >> N >> X;
    long long int S[300];
	for(int i = 0; i < N; i++){
		cin >> S[i];
	}
    sort(S, S + N);
    long long int num = 1;
    for(int i = 1; i <= N; i++){
        num *= i;
        num %= MOD;
    }
    DP[X] = num;
    for(int i = N - 1; i >= 0; i--){
        num = pow_m1(i + 1);
        for(int j = 0; j <= X; j++){
            DP2[j] = 0;
        }
        for(int j = 0; j <= X; j++){
            DP2[j % S[i]] += DP[j] * num;
            DP2[j % S[i]] %= MOD;
            DP2[j] += DP[j] * (num * i % MOD);
            DP2[j] %= MOD;
        }
        for(int j = 0; j <= X; j++){
            DP[j] = DP2[j];
        }
    }
    long long int ans = 0;
    for(int i = 1; i <= X; i++){
        ans += i * DP[i];
        ans %= MOD;
    }
    cout << ans << endl;
}