#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, A;
  ll S = 0;
  map<ll, int> mp;
  mp[0] = 1;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    S += A;
    mp[S]++;
  }
  ll ans = 0;
  for (auto i : mp) {
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans << "\n";
}
