#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  vector<long long>(A);
  (A).push_back((0));
  map<long long, int> S;
  cin >> N;
  for (int x = 0; x < (N); x++) {
    int a;
    cin >> a;
    (A).push_back((a + A.at(x)));
    S[A.at(x + 1)]++;
  }
  long long ans = S[0];
  for (int y = (1); y < (N + 1); y++) {
    ans += S[A.at(y)] * (S[A.at(y)] - 1) / 2;
    S[A.at(y)] = 0;
  }
  cout << ans << endl;
}
