stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define rep(i,x,n) for(int i = x; i < (int)(n); i++)

#define rep_ll(i,x,n) for(ll i = x; i < (ll)(n); i++)

using namespace std;

typedef long long ll;

typedef unsigned long long u_ll;

typedef pair<int, int> pair_;

const long double PI = (acos(-1));

const int INF = 1001001001;

const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};

ll mod = 1000000007;

int main(){

    int n;

    cin >> n;

    priority_queue<int> q;

    vector<int> a(n);

    rep(i, 0, n) cin >> a[i];

    sort(a.begin(), a.end());

    int aamax=1000002;

    vector<int> aa(aamax, 0);

    rep(i, 0, n){

        if(aa[a[i]]!=0){

            aa[a[i]]=2;

            continue;

        }

        for(int j=a[i]; j< aamax;j+=a[i]) aa[j]++;

    }

    int cnt=0;

    rep(i, 0, n) if(aa[a[i]]==1) cnt++; 



    cout << cnt;



    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define rep(i,x,n) for(int i = x; i < (int)(n); i++)

#define rep_ll(i,x,n) for(ll i = x; i < (ll)(n); i++)

using namespace std;

typedef long long ll;

typedef unsigned long long u_ll;

typedef pair<int, int> pair_;

const long double PI = (acos(-1));

const int INF = 1001001001;

const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};

ll mod = 1000000007;

int main(){

    const int MAX_SIZE=1000005;

    bool num[MAX_SIZE];

    rep(i, 0, MAX_SIZE) num[i]=false;

    int n;

    cin >> n;

    vector<int> a(n);

    rep(i, 0, n) cin >> a[i];

    sort(a.begin(), a.end());

    int cnt=0;

    //エラトステネスの篩

    rep(i, 0, n){

        if(num[a[i]]==true) continue;

        //重複判定、昇順なのでこれでOK

        if(!(i<n-1&&a[i]==a[i+1])) cnt++;



        for(int j = a[i]; j < MAX_SIZE; j+=a[i]) num[j]=true;

    }

    cout << cnt;



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

const ll MOD = 1e9 + 7/*998244353*/;

const ll INF = 1LL << 60;

ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);

//

void fun(vector<ll>& vec, int a){

    for(int i = 1; i <= sqrt(a); i++){

        if(a % i == 0) {vec.push_back(i); vec.push_back(a / i);}

    }

}

int main(){

    int n;

    cin >> n;

    set<ll> nums;

    vector<ll> in(n);

    vector<bool> flag(1e6 + 1, false);

    vector<vector<ll>> divisor(n, vector<ll>());

    for(int i = 0; i < n; i++){

        int x; cin >> x;

        in[i] = x;

        if(flag[x]) nums.insert(x);

        flag[x] = true;

        fun(divisor[i], x);

    }

    ll ans = 0;

    for(int i = 0; i < n; i++){

        if(nums.count(in[i])) continue;

        bool bl = true;

        for(auto itr : divisor[i]){

            if(in[i] == itr) continue;

            if(flag[itr]) bl = false;

        }

        if(bl) ans++;

    }

    cout << ans;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

const ll MOD = 1e9 + 7/*998244353*/;

const ll INF = 1LL << 60;

ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);

//

int main(){

    int n;

    cin >> n;

    vector<ll> nums(n);

    set<ll> appeared, reappeared;

    ll mx = 0;

    for(int i = 0; i < n; i++) {cin >> nums[i]; mx = max(mx, nums[i]);}

    vector<bool> available(mx + 1, true);

    for(int i = 0; i < n; i++){

        if(appeared.count(nums[i])) {reappeared.insert(nums[i]); continue;}

        appeared.insert(nums[i]);

        for(int j = 2; j <= mx / nums[i]; j++){

            //cout << nums[i] * j;

            available[nums[i] * j] = false;

        }

    }

    ll ans = 0;

    for(int i = 0; i < n; i++){

        if(reappeared.count(nums[i])) continue;

        if(available[nums[i]]) ans++;

    }

    //for(int i = 0; i <= mx; i++) cout << available[i] << " ";

    cout << ans;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
// D - Not Divisible

#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;

#define rep(i,n) for(int i=0;i<(int)(n);++i)



int main(){

	int N; cin>>N;

	vi A(N);

	vi l(1000000+1, 0);

	vi c(1000000+1, 0);

	// int mn = 0;

	int mx = 0;

	rep(i, N){

		int a; cin>>a;

		A[i] = a;

		// mn = min(mn, a);

		mx = max(mx, a);

		c[a]++;

	}



	for(int a:A){

		for(int i=a*2; i<=mx; i+=a) l[i] = 1;

	}



	int ans = 0;

	for(int a:A){

		if(!l[a] && c[a] <= 1) ans++;

	}

	cout<< ans <<endl;

}


// Optimized solution to the same problem (faster):
// D - Not Divisible

#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;

#define rep(i,n) for(int i=0;i<(int)(n);++i)



int main(){

	int N; cin>>N;

	vi A(N);

	int mx = 0;

	rep(i, N){

		cin>>A[i];

		mx = max(mx, A[i]);

	}

	vi c(mx+1, 0);

	for(int a:A){

		for(int i=a; i<=mx; i+=a) c[i]++;

	}

	int ans = 0;

	for(int a:A) if(c[a] == 1) ans++;

	cout<< ans <<endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)

#define inf 1000000000000000000

#define mod 1000000007

#define mod2 998244353

#define pi acos(-1)

#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int main() {

  cin.tie(nullptr);

  ios::sync_with_stdio(false);

  cout << setprecision(15) << fixed;



  ll N; cin >> N;

  vector<ll> A(N);

  rep(i, N) cin >> A[i];



  map<ll, ll> Counter;

  vector<bool> ans(1000001, true);

  for (auto i : A) {

    Counter[i]++;

    if (Counter[i] > 1) continue;

    for (ll j = 2 * i; j < 1000001; j += i) {

      ans[j] = false;

    }

  }



  ll cnt = 0;

  for (auto i : A) {

    if (ans[i] && Counter[i] == 1) cnt++;

  }



  cout << cnt << endl;

}


// Optimized solution to the same problem (faster):
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)

#define inf 1000000000000000000

#define mod 1000000007

#define mod2 998244353

#define pi acos(-1)

#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int main() {

  cin.tie(nullptr);

  ios::sync_with_stdio(false);

  cout << setprecision(15) << fixed;



  ll N; cin >> N;

  vector<ll> A(N);

  rep(i, N) cin >> A[i];

  set<ll> Used;

  vector<bool> ans(1000001, true);

  for (auto i : A) {

    if (Used.find(i) != Used.end()) {

      ans[i] = false;

      continue;

    }

    for (ll j = 2 * i; j < 1000001; j += i) {

      ans[j] = false;

    }

    Used.insert(i);

  }



  ll cnt = 0;

  for (auto i : A) {

    if (ans[i]) cnt++;

  }



  cout << cnt << endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)

#define all(v) v.begin(), v.end()

//#define MOD 1000000007

const int INF = 1LL<<30;



int cnt[1010101];

bool ok[1010101];



int main() {

    int n;

    cin>>n;

    vector<int> a(n);

    rep(i,n) cin>>a[i];



    rep(i,n) cnt[a[i]]++;

    for(int x=1;x<1010101;x++) ok[x]=true;

    for(int x=1;x<1010101;x++){

        if(0<cnt[x]){

            if(1<cnt[x]) ok[x]=false;

            for(int x2=x*2;x2<1010101;x2+=x) ok[x2]=false;

        }

    }



    int ans=0;

    rep(i,n){

        if(ok[a[i]]) ans++;

    }



    cout<<ans<<endl;



}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)

#define all(v) v.begin(), v.end()

#define MOD 1000000007

const int INF = 1LL<<30;



int main(){

    int n;

    cin>>n;

    vector<int> a(n);

    rep(i,n) cin>>a[i];



    sort(all(a));

    vector<bool> ok(1000010,false);



    rep(i,n){

        if(ok[a[i]]) continue;

        for(int j=2*a[i];j<=a[n-1];j+=a[i]) ok[j]=true;

        if(a[i]==a[i+1]) ok[a[i]]=true;

    }



    int ans=0;

    rep(i,n){

        if(!ok[a[i]]){

            ans++;

            //cout<<a[i]<<endl;

        }

    }



    cout<<ans<<endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)

#define all(v) v.begin(), v.end()

#define MOD 1000000007

const int INF = 1LL<<30;



int main(){

    int n;

    cin>>n;

    vector<int> a(n);

    set<int> b;

    rep(i,n){

        cin>>a[i];

        b.insert(a[i]);

    }



    sort(all(a));

    vector<bool> ok(1000010,true);

    rep(i,n-1){

        if(a[i]==a[i+1]) ok[a[i]]=false;

    }

    

    for(auto x : b){

        for(int j=2*x;j<1000010;j+=x) ok[j]=false;

    }

    



    int ans=0;

    for(auto x : b){

        if(ok[x]){

            ans++;

            //cout<<a[i]<<endl;

        }

    }



    cout<<ans<<endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)

#define all(v) v.begin(), v.end()

#define MOD 1000000007

const int INF = 1LL<<30;



int main(){

    int n;

    cin>>n;

    vector<int> a(n);

    rep(i,n) cin>>a[i];



    sort(all(a));

    vector<bool> ok(1000010,false);



    rep(i,n){

        if(ok[a[i]]) continue;

        for(int j=2*a[i];j<=a[n-1];j+=a[i]) ok[j]=true;

        if(a[i]==a[i+1]) ok[a[i]]=true;

    }



    int ans=0;

    rep(i,n){

        if(!ok[a[i]]){

            ans++;

            //cout<<a[i]<<endl;

        }

    }



    cout<<ans<<endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using ld = long double;

using vl = vector<ll>;

using vll = vector<vl>;

using Pll = pair<ll, ll>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

#define all(v) v.begin(), v.end()

#define sz(x) ((int) x.size())

#define pb push_back

#define mp make_pair

#define mt make_tuple

#define F first

#define S second

const int MOD = 1e9+7;

const ll INF = 2e18;

template<class T> void print(const T& t){ cout << t << endl; }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int gcd(int a,int b){return b?gcd(b,a%b):a;}



int main(){

  ll n;

  cin >> n;

  vl a(n);

  vector<bool> z(1000007, true);

  vector<bool> z1(1000007, false);

  rep(i, n){

    cin >> a[i];

    if(z[a[i]]){

      for (ll j = 2; a[i] * j < 1000007; j++){

        z[a[i] * j] = false;

      }

      if(z1[a[i]])z[a[i]] = false;

      z1[a[i]] = true;

    }

  }

  ll ans = 0;

  rep(i, n){

    if(z[a[i]])

      ans++;

  }

  print(ans);

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

int exist[1000005];

int max1;

int min1=0x3f3f3f3f;

int end1;

bool flag[1000005];

void sieve()

{

    for(int i=min1;i<=max1;i++)

    {

    	if(exist[i]==1)

        {

            for(int j=2*i;j<=max1;j+=i)

            {

                if(exist[j]&&flag[j]==0)

                {

                    exist[j]--;

                    end1--;

                }

            }

        }

    }

}

int x;

int main() 

{

    int n;cin>>n;

	for(int i=1;i<=n;i++)

    {

        cin>>x;

        exist[x]++;

        max1=max(max1,x);

        min1=min(min1,x);

    }

    for(int i=min1;i<=max1;i++)

    {

    	if(exist[i]==1)

    	{

    		end1++;

		}

		else if(exist[i]>1)

		{

			exist[i]=1;

			flag[i]=1;

		}

	}

    sieve();

    cout<<end1;

}






// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<iomanip>

#include<cmath>

#include<string>

#include<vector>

#include<list>

#include<algorithm>

#include<map>

#include<set>

#include<queue>

#include<stack>

using namespace std;

typedef long long ll;

#define fi first

#define se second

#define mp make_pair

#define rep(i, n) for(int i=0;i<n;++i)

#define rrep(i, n) for(int i=n;i>=0;--i)

const int inf=1e9+7;

const ll mod=1e9+7;

const ll big=1e18;

const double PI=2*asin(1);



int main() {

  int N;

  cin>>N;

  vector<int> A(N);

  for(int i=0;i<N;++i){

    cin>>A[i];

  }

  sort(A.begin(), A.end());

  map<int, int> amap;

  int tmpA;

  bool ok[1000005];

  for(int i=0;i<1000005;++i){

    ok[i] = false;

  }

  for(int i=0;i<N;++i){

    tmpA = A[i];

    for(int j=1;j*j<=tmpA;++j){

      if(tmpA%j==0){

        if(amap[j]>0 || amap[tmpA/j]>0) {

          ok[tmpA] = true;

        }

      }

    }

    amap[A[i]]++;

  }

  int ans = 0;

  for(int i=0;i<N;++i){

    if(ok[A[i]]==false) {

      ans++;

    }

  }

  cout<<ans<<endl;

}




// Optimized solution to the same problem (faster):
#include<iostream>

#include<iomanip>

#include<cmath>

#include<string>

#include<cstring>

#include<vector>

#include<list>

#include<algorithm>

#include<map>

#include<set>

#include<queue>

#include<stack>

using namespace std;

typedef long long ll;

#define fi first

#define se second

#define mp make_pair

#define mt make_tuple

#define pqueue priority_queue

const int inf=1e9+7;

const ll mod=1e9+7;

const ll mod1=998244353;

const ll big=1e18;

const double PI=2*asin(1);



int main() {

  int N;

  cin>>N;

  vector<int> A(N);

  for(int i=0;i<N;++i) cin>>A[i];

  sort(A.begin(), A.end());

  int ans[A[A.size()-1]+1];

  for(int i=0;i<=A[A.size()-1];++i) ans[i] = 0;

  map<int, int> amap;

  for(int i=0;i<N;++i) {

    if(ans[A[i]]>0) continue;

    amap[A[i]]++;

    for(int j=2;A[i]*j<=A[A.size()-1];++j) {

      ans[A[i]*j]++;

    }

  }

  int ans1 = 0;

  for(int i=0;i<=A[A.size()-1];++i) {

    if(amap[i]==1 && ans[i]==0) ans1++;

  }

  cout<<ans1<<endl;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back

#define mp make_pair

#define f first

#define s second

#define ll long long

#define endl "\n"

using namespace __gnu_pbds;

template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using namespace std;

const int N = 1e6 + 10;

const ll inf = 1e18 + 10, mod = 1e9 + 7;

int n, m[N], a[N], ans;

int main()

{

    ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

    //freopen("lca_rmq.in", "r", stdin);

    //freopen("lca_rmq.out", "w", stdout);

    cin >> n;

    for(int i = 1; i <= n; i++)

    {

        cin >> a[i];

        m[a[i]]++;

    }

    for(int i = 1; i <= n; i++)

    {

        int t = 0;

        for(int j = 2; j * j <= a[i]; j++)

        {

            if(a[i] % j == 0)

            {

                if(m[j])t = 1;

                if(j * j != a[i] && m[a[i] / j])t = 1;

            }

        }

        if(m[1] && a[i] != 1)t = 1;

        if(!t && m[a[i]] <= 1)ans++;

    }

    cout << ans;

}
































// Optimized solution to the same problem (faster):
#include <stdio.h>

#define N 1000001



int c[N] = {0}, a[200002];

char f[N] = {0};



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, m = 0, i, j, ans = 0, x;

		

	n = read();

	for(i = 0; i < n; i++){

		a[i] = x = read();

		if(x > m) m = x;

		c[x]++;

	}

	for(i = 1; i <= m; i++){

		if(!c[i]) continue;

		for(j = i << 1; j <= m; j += i) f[j] = 1;

	}

	for(i = 0; i < n; i++){

		x = a[i];

		if(c[x] == 1 && !f[x]) ans++;

	}

	printf("%d\n", ans);	

			

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _USE_MATH_DEFIMES

#include <algorithm>

#include <array>

#include <bitset>

#include <cassert>

#include <cctype>

#include <climits>

#include <clocale>

#include <cmath>

#include <complex>

#include <cstdio>

#include <cstdlib>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <regex>

#include <set>

#include <sstream>

#include <stack>

#include <string>

#include <tuple>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>



const int MOD = 1'000'000'007;

const int INF = 1'000'000'000; //1e9

const int NIL = -1;

const long long LINF = 1'000'000'000'000'000'000; // 1e18

const long double EPS = 1E-10;



template<class T, class S> inline bool chmax(T &a, const S &b){

    if(a < b){

        a = b; return true;

    }

    return false;

}

template<class T, class S> inline bool chmin(T &a, const S &b){

    if(b < a){

        a = b; return true;

    }

    return false;

}















int main(){

    int N; std::cin >> N;

    std::vector<int> A(N);

    int mxa(0);

    for(int i(0); i < N; ++i){

        std::cin >> A[i];

        chmax(mxa, A[i]);

    }

    std::sort(std::begin(A), std::end(A));

    std::vector<bool> okay(mxa + 1, true), has(mxa + 1, false);

    for(int i(0); i < N; ++i){

        if(has[A[i]]) okay[A[i]] = false;

        if(okay[A[i]]){

            for(int j(2*A[i]); j <= mxa; j += A[i]){

                okay[j] = false;

            }

            has[A[i]] = true;

        }

    }

    int ans(0);

    for(int i(0); i < N; ++i) if(okay[A[i]]) ++ans;

    std::cout << ans << std::endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#define N 1000001



int c[N] = {0}, a[200002];

char f[N] = {0};



int read()

{

	char c;

	while((c = getchar()) < 48 || c > 57);

	int x = c - 48;

	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;

	return x;

}



int main()

{		

	int n, m = 0, i, j, ans = 0, x;

		

	n = read();

	for(i = 0; i < n; i++){

		a[i] = x = read();

		if(x > m) m = x;

		c[x]++;

	}

	for(i = 1; i <= m; i++){

		if(!c[i]) continue;

		for(j = i << 1; j <= m; j += i) f[j] = 1;

	}

	for(i = 0; i < n; i++){

		x = a[i];

		if(c[x] == 1 && !f[x]) ans++;

	}

	printf("%d\n", ans);	

			

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int main()

{

	int n;

	cin >> n;

	vector<int> a(n);

	int c[1000100] = {};

	for (int i = 0; i < n; i++) {

		cin >> a[i];

		c[a[i]]++;

	}

	if (c[1] >= 2) {

		cout << 0 << endl;

		return 0;

	} else if (c[1] == 1) {

		cout << 1 << endl;

		return 0;

	}



	vector<vector<int>> b(n);

	for (int i = 0; i < n; i++) {

		for (int j = 2; j * j <= a[i]; j++) {

			if (a[i] % j == 0) {

				b[i].emplace_back(j);

				b[i].emplace_back(a[i] / j);

			}

		}

	}

	

	int ans = 0;

	for (int i = 0; i < n; i++) {

		if (c[a[i]] >= 2) {

			continue;

		}

		bool ok = true;

		for (auto & j : b[i]) {

			if (c[j] != 0) {

				ok = false;

				break;

			}

		}

		if (ok) {

			ans++;

		}

	}

	cout << ans << endl;



	return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int c[1000100] = {};

int f[1000100] = {};



int main()

{

	int n;

	cin >> n;

	vector<int> a(n);

	for (int i = 0; i < n; i++) {

		cin >> a[i];

		c[a[i]]++;

	}

	sort(a.begin(), a.end());

	a.erase(unique(a.begin(), a.end()), a.end());

	

	for (int i = 0; i < a.size(); i++) {

		for (int j = a[i]; j < 1000100; j += a[i]) {

			f[j] += c[a[i]];

		}

	}



	int ans = 0;

	for (int i = 0; i < a.size(); i++) {

		if (f[a[i]] == 1) {

			ans++;

		}

	}

	cout << ans << endl;



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define MM 1000000000

#define MOD MM+7

#define MAX 101000

#define MAP 110

#define initial_value -1

#define Pair pair<int,int>

#define lPair pair<ll,ll>

#define chmax(a,b) (a<b ? a=b:0)

#define chmin(a,b) (a>b ? a=b:0)

int dx[4] = {-1,0,1,0};

int dy[4] = {0,-1,0,1};



vector<int> places[200200];

ll dp[200200];

void add(ll &a, ll b) { a+=b; if(a >= MOD) a -= MOD;}

int main(){

    int N; cin >> N;

    map<char,int> mp;

    string s; cin >> s;

    for(int i = 0; i < N; i++){

        mp[s[i]]++;

    }

    ll ans = 1;

    for(char t = 'a'; t <= 'z'; t++){

        if(mp[t] == 0) continue;

        ans *= (mp[t]+1);

        ans %= MOD;

    }

    cout << ans-1 << endl;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long long int llint;

#define MM 1000000000

#define MOD MM+7

#define MAX 101000

#define MAP 110

#define initial_value -1

#define Pair pair<int,int>

#define chmax(a,b) (a<b ? a=b:0)

#define chmin(a,b) (a>b ? a=b:0)

#define INF (1 << 29) //536870912

int dx[4] = {-1,0,1,0};

int dy[4] = {0,-1,0,1};

int main(){

    int n; cin >> n;

    string s; cin >> s;

    map<char,int> mp;

    for(int i = 0; i < n; i++){

        mp[s[i]]++;

    }

    ll ans = 1;

    for(char t = 'a'; t <= 'z'; t++){

        if(mp[t] == 0) continue;

        ans *= (mp[t] + 1);

        ans %= MOD;

    }

    cout << ans-1 << endl;

}



 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

map<char , int>m;

char c;

int n;

long long sum;

int main(){

	cin >> n;

	for(int i = 1 ; i <= n ; i++){

		cin >> c;

		m[c]++; 

	}

	sum = 1;

	for(char i = 'a' ; i <= 'z' ; i++){

		sum *= (m[i] + 1);

		sum %= mod;

	}

	cout << sum - 1 << endl;

}

// Optimized solution to the same problem (faster):
#include<cstdio>



using namespace std;



char s[100002];

int z[26];

int main(){

	int n;

	scanf("%d%s",&n,s+1);

	for(int i=1;i<=n;i++)

		z[s[i]-'a']++;

	int ans=1;

	for(int i=0;i<26;i++)

		ans=1ll*ans*(z[i]+1)%1000000007;

	printf("%d\n",(ans-1+1000000007)%1000000007);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



const int mod = int(1e9) + 7;



int n;

char s[100005];

int cnt[26];



int main() {

	scanf("%d%s", &n, s);

	for (int i = 0; i < n; ++i) ++cnt[s[i] - 'a'];

	int ans = 1;

	for (int i = 0; i < 26; ++i) ans = 1LL * ans * (cnt[i] + 1) % mod;

	printf("%d\n", (ans - 1 + mod) % mod);

}

// Optimized solution to the same problem (faster):
#include<cstdio>



using namespace std;



char s[100002];

int z[26];

int main(){

	int n;

	scanf("%d%s",&n,s+1);

	for(int i=1;i<=n;i++)

		z[s[i]-'a']++;

	int ans=1;

	for(int i=0;i<26;i++)

		ans=1ll*ans*(z[i]+1)%1000000007;

	printf("%d\n",(ans-1+1000000007)%1000000007);

}

// Fastest known solution for this problem: