#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<long long int, long long int> x;
  x[0] = 1;
  long long int p = 0;
  int ans = 0;
  while (n--) {
    int y;
    cin >> y;
    p += y;
    ans += x[p];
    x[p]++;
  }
  cout << ans << endl;
  return 0;
}
