#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> S(N + 1);
  S.at(0) = 0;
  for (int i = 1; i <= N; i++) {
    long long A;
    cin >> A;
    S.at(i) = S.at(i - 1) + A;
  }
  sort(S.begin(), S.end());
  long long answer = 0;
  long long count = 0;
  for (int i = 1; i <= N; i++) {
    if (S[i - 1] = S[i]) {
      count++;
      answer += count;
    } else {
      count = 0;
    }
  }
  cout << answer << endl;
}
