#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;
int main() {
  std::ios::sync_with_stdio(false);
  map<int, int> p;
  p[0]++;
  int n;
  cin >> n;
  int s = 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s += x;
    res += p[s];
    p[s]++;
  }
  cout << res << "\n";
  return 0;
}
