#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int sum = 0;
  vector<int> V(N + 1, 0);
  for (int i = 0; i < N; i++) {
    sum += A.at(i);
    V.at(i + 1) = sum;
  }
  sort(V.begin(), V.end());
  V.push_back(V.at(N) + 1);
  long long cnt = 1;
  long long ans = 0;
  for (int i = 0; i < N + 1; i++) {
    if (V.at(i) == V.at(i + 1))
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  cout << ans << endl;
}
