#include <bits/stdc++.h>
using namespace std;
int a[100005];
int n;
int main() {
  while (~scanf("%d", &n)) {
    long long sum = 0;
    map<long long, int> s;
    long long ans = 0;
    s[0] = 1;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      ans += a[i];
      sum += s[ans];
      s[ans]++;
    }
    cout << sum << endl;
  }
  return 0;
}
