#include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 char get(char c,int a){ a += 26; a %= 26; rep(i,a){ c++; if(c>'Z')c = 'A'; } return c; } int main() { int n; cin>>n; string s; cin>>s; fenwick_tree F(n); rep(i,n)F.add(i,1); vector c(26); rep(i,n){ c[s[i]-'A']++; } int add = 0; while(true){ int c0 = 0; c0 += c[get('A',-add)-'A']; c0 += c[get('G',-add)-'A']; c0 += c[get('C',-add)-'A']; c0 += c[get('T',-add)-'A']; if(c0==0)break; int ok = 0,ng = n; while(ng-ok>1){ int mid = (ok+ng)/2; if(F.sum(0,mid)