#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<long long, int> m;
  m[0]++;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    sum += x;
    m[sum]++;
  }
  long long ans = 0;
  for (auto p : m) {
    ans += (p.second) * (p.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
