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