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