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