#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) cin >> A[i];
  vector<int> S(n + 1, 0);
  for (int i = 0; i < n; ++i) S[i + 1] = S[i] + A[i];
  map<int, int> m;
  for (int i = 0; i < n + 1; ++i) ++m[S[i]];
  long ans = 0;
  for (auto& x : m) {
    long value = x.second;
    long pat = value * (value - 1) / 2;
    ans += pat;
  }
  cout << ans << endl;
}
