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