#include <bits/stdc++.h>
using namespace std;
map<int, int> Q;
int S[200020];
int main() {
  int n;
  cin >> n;
  Q[0]++;
  cin >> S[0];
  Q[S[0]] = 1;
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    S[i] = S[i - 1] + a;
    Q[S[i]] = Q[S[i]] + 1;
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int d = Q[S[i]];
    sum += (d * (d - 1) / 2);
    Q[S[i]] = 0;
  }
  cout << sum;
  return 0;
}
