#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  long long c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0)
      c[i] = a[i];
    else
      c[i] = c[i - 1] + a[i];
  }
  long long ans = 0;
  map<long long, int> seen;
  for (int i = 0; i < n; i++) {
    int cur = c[i];
    if (cur == 0) {
      ans += (seen[cur] + 1);
    } else {
      ans += seen[cur];
    }
    seen[cur]++;
  }
  cout << ans << endl;
}
