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