#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, A, x = 0;
  cin >> N;
  vector<long long int> S(N);
  cin >> S.at(0);
  for (int i = 1; i < N; i++) {
    cin >> A;
    S.at(i) = S.at(i - 1) + A;
  }
  sort(S.begin(), S.end());
  int j = -1;
  for (int i = 0; i < N; i++) {
    if (i == N - 1 || S.at(i + 1) != S.at(i)) {
      int n = i - j;
      x += n * (n - 1) / 2;
      j = i;
    }
  }
  cout << x << endl;
}
