#include <bits/stdc++.h>
using namespace std;
long long N, A[200002] = {}, ans = 0;
map<long long, int> sf;
int main() {
  cin >> N;
  sf[0] = 1;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    A[i] += A[i - 1];
    if (sf.find(A[i]) == sf.end()) sf[A[i]] = 0;
    sf[A[i]]++;
  }
  for (auto itr = sf.begin(); itr != sf.end(); itr++) {
    int cnt = itr->second;
    ans += (cnt * (cnt - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
