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