#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> S(N + 1);
  map<long long, int> K;
  K[0]++;
  for (int i = 1; i < N + 1; i++) {
    long long A;
    cin >> A;
    S[i] = S[i - 1] + A;
    K[S[i]]++;
  }
  long long count = 0;
  for (auto i : K) {
    count += i.second * (i.second - 1) / 2;
  }
  cout << count << endl;
}
