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