#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long A[200050];
  for (int i = 0; i < N; ++i) cin >> A[i];
  long long S[N + 1];
  S[0] = 0;
  for (int i = 1; i <= N; ++i) {
    S[i] = S[i - 1] + A[i - 1];
  }
  sort(S, S + N + 1);
  int res = 0;
  int m = 1;
  for (int i = 0; i < N; ++i) {
    if (S[i] == S[i + 1]) {
      ++m;
      if (i == N - 1) {
        if (S[i] != 0)
          res += m * (m - 1) / 2;
        else {
          res += m - 1 + (m - 1) * (m - 2) / 2;
        }
      }
    } else {
      if (S[i] != 0)
        res += m * (m - 1) / 2;
      else {
        res += m - 1 + (m - 1) * (m - 2) / 2;
      }
      m = 1;
    }
  }
  cout << res << endl;
}
