#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
long long sigma, ans, N;
long long a[200000];
multiset<long long> s;

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    sigma += a[i];
    if (sigma == 0) {
      ans++;
    }
    s.insert(sigma);
  }
  while (!s.empty()) {
    set<int>::iterator i = s.begin();
    size_t n = s.count(*i);
    if (n >= 2) {
      ans += n * (n - 1) / 2;
    }
    s.erase(*i);
  }

  cout << ans << endl;
  return 0;
}