#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<ll, int> mp;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> s(n + 1);
  for (int i = 0; i < (int)(n); ++i) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }
  for (int i = 0; i < (int)(n + 1); ++i) {
    mp[s[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < (int)(n); ++i) {
    mp[s[i]]--;
    ans += mp[s[i]];
  }
  cout << ans << endl;
  return (0);
}
