#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
int S[200005];
int c, t;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> N;
  for (int i = (0); i < (N); ++i) {
    int A;
    cin >> A;
    S[i + 1] = A + S[i];
  }
  sort(S, S + N + 1);
  for (int i = (0); i < (N); ++i) {
    if (S[i + 1] == S[i])
      c++;
    else {
      t += (c + 1) * c / 2;
      c = 0;
    }
  }
  t += (c + 1) * c / 2;
  cout << t << endl;
  return 0;
}
