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