#include <bits/stdc++.h>
using namespace std;
long long pref[300002];
map<long long, int> x;
int main() {
  int n;
  cin >> n;
  long long a[300000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    pref[i + 1] = pref[i] + a[i];
  }
  long long ans;
  for (int i = n; i > -1; i--) {
    ans += x[pref[i]];
    x[pref[i]]++;
  }
  cout << ans;
  return 0;
}
