#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; int n; int a[150000]; signed main() { int i; cin >> n; rep(i, n) cin >> a[i]; assert(1 <= n && n <= 150000); int minA = a[0], maxA = a[0]; rep(i, n) minA = min(minA, a[i]); rep(i, n) maxA = max(maxA, a[i]); assert(1 <= minA && maxA <= 100); vector ra(n + 1); int ans = n * (n + 1) / 2; for (int x = minA; x <= maxA; x++) { ra[0] = 0; rep(i, n) { ra[i + 1] = ra[i] + a[i] - x; } vector rb = ra; rb.erase(unique(rb.begin(), rb.end()), rb.end()); sort(ra.begin(), ra.end()); sort(rb.begin(), rb.end()); int cnt = 0; rep(i, n + 1) { if (i > 0 && ra[i] != ra[i - 1]) { ans -= cnt * (cnt - 1) / 2; cnt = 0; } cnt++; } ans -= cnt * (cnt - 1) / 2; cnt = 0; rep(i, rb.size()) { if (i > 0 && rb[i] != rb[i - 1]) { ans += cnt * (cnt - 1) / 2; cnt = 0; } cnt++; } ans += cnt * (cnt - 1) / 2; } ans++; //初期状態の分を足す cout << ans << endl; return 0; }