#include <bits/stdc++.h>
using namespace std;
long long a[100100], s[100100];
map<long long, long long> me;
int main() {
  int n;
  long long ze = 1, out = 0, sum = 0;
  me[0]++;
  cin >> n;
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    out += me[sum];
    me[sum]++;
  }
  cout << out << endl;
}
