//定数倍が軽そうなもの #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #define rep(i, n) for(i = 0; i < n; i++) using namespace std; int n; int a[70000], ra[70001]; int b[70000]; signed main() { int i, j; cin >> n; rep(i, n) cin >> a[i]; rep(i, n) ra[i + 1] = ra[i] + a[i]; assert(1 <= n && n <= 70000); int maxA = a[0], minA = a[0]; rep(i, n) maxA = max(maxA, a[i]); rep(i, n) minA = min(minA, a[i]); assert(maxA <= 50); assert(minA >= 1); long long ans = ((long long)n) * (n - 1) / 2 + 1; rep(i, n) b[i] = a[i]; for (i = 2; i <= n; i++) { rep(j, n) b[j] += a[j]; for (j = 0; j + i <= n; j++) { //区間[j, j + i)を確認 if (b[j] == ra[j + i] - ra[j]) ans--; else if (b[j + i - 1] == ra[j + i] - ra[j]) ans--; } } cout << ans << endl; return 0; }