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