#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r = 0;
  cin >> n;
  vector<int> a(n);
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i != 0) a[i] += a[i - 1];
  }
  for (int i = 0; i < n; i++) m[a[i]]++;
  for (auto p : m) r += p.second * (p.second - 1) / 2;
  cout << r + m[0];
}
