#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool debug = false;
int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  unordered_map<ll, ll> mp;
  mp[A[0]]++;
  for (int i = 1; i < N; i++) {
    A[i] += A[i - 1];
    mp[A[i]]++;
  }
  ll ans = mp[0];
  for (auto itr : mp) {
    ans += max((mp[A[itr.second]] * (mp[A[itr.second]] - 1)) / 2, 0LL);
  }
  cout << ans << endl;
  return 0;
}
