#include <iostream>
#include <string>
using namespace std;
int pre[101010] = {0,};
int main() {
int n;
cin >> n;
string s;
cin >> s;
for (int i = 1; i <= n; i++) {
pre[i] = s[i] - '0' + pre[i-1];
}
long long cnt = 0;
for (int i = 1; i <= n; i++) {
for (int j = i; j <= n; j++) {
int sum = pre[j] - pre[i - 1];
int len = j - i + 1;
if (sum == len) {
cnt++;
}
}
}
cout << cnt;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: