#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353LL;
int n;
string s;
int main() {
  cin >> n;
  cin >> s;
  long long int final_result = 0;
  for (char c = 'a'; c <= 'z'; c++) {
    int l = n, r = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] != c) {
        l = min(l, i), r = max(r, i);
      }
    }
    final_result = (final_result + 1LL * (l + 1) * (n - r) - 1LL) % mod;
  }
  cout << final_result + 1LL << endl;
}
