#include <stdio.h>
#include <math.h>
int const M=1234567891;
int main() {
int n;
long long r=1;
scanf("%d",&n);
long long sum=0;
char str[n+1];
scanf("%s",str);
for (int i=0; i<n; i++) {
sum=sum+(str[i]-'a'+1)*r%M;
r=(r*31)%M;
}
sum=sum%M;
printf("%lld",sum);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: