#include <bits/stdc++.h>
using namespace std;
long long acc[100001];
int main() {
  int n;
  long long prev = 0;
  long long total = 0;
  map<long long, int> m;
  m[0] = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    acc[i] = a + prev;
    if (m.find(acc[i]) == m.end()) {
      m[acc[i]] = 0;
    }
    total += m[acc[i]];
    m[acc[i]]++;
    prev = acc[i];
  }
  cout << total << endl;
  return (0);
}
