#include #include #include #include using namespace std; int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; ++i) cin >> a[i]; vector> mp(30); vector sum(n + 1); for (int i = 0; i < n; ++i) sum[i + 1] = sum[i] + a[i]; mp[a[0] - 1][0] = 1; long long ans = (long long)(n + 1) * n / 2 + 1; for (int i = 1; i <= n; ++i) { for (int j = 0; j < 30; ++j) { int tmp = sum[i] - (j + 1) * i; if (mp[j].find(tmp) != mp[j].end()) ans -= mp[j][tmp]; } if (i < n) mp[a[i] - 1][sum[i] - i * a[i]]++; } cout << ans << endl; }