#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<int, int> mpa, mpb;
int main() {
  ll N;
  cin >> N;
  ll a[200100];
  a[0] = 0;
  int t;
  for (ll i = 0; i < N; i++) {
    cin >> t;
    a[i + 1] = a[i] + t;
  }
  sort(a, a + N + 1);
  ll ans = 0;
  ll k = 1;
  for (int i = 1; i <= N; i++) {
    if (a[i] == a[i - 1]) {
      k++;
    } else {
      ans += k * (k - 1) / 2;
      k = 1;
    }
  }
  cout << ans + k * (k - 1 / 2);
}
