#include <bits/stdc++.h>
using namespace std;
map<long long, int> p;
map<long long, int>::iterator it;
int main() {
  int n;
  cin >> n;
  int x;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    sum += x;
    p[sum]++;
  }
  int ans = 0;
  for (it = p.begin(); it != p.end(); it++) {
    int s = it->second;
    if (it->first == 0)
      ans += (s * (s + 1) / 2);
    else
      ans += (s * (s - 1) / 2);
  }
  cout << ans << endl;
  return 0;
}
