#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  ll p = 0;
  map<ll, int> m;
  m[0]++;
  for (int i = 0; i < N; i++) {
    ll A;
    cin >> A;
    m[A + p]++;
    p = A + p;
  }
  ll ans = 0;
  for (auto iter = m.begin(); iter != m.end(); ++iter) {
    ans += (iter->second) * (iter->second - 1) / 2;
  }
  cout << ans << endl;
}
