#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
using namespace std;
int main() {
  int N, i, ans, scount;
  cin >> N;
  vector<int> A(N), S(N + 1);
  for (i = 0; i < N; i++) cin >> A[i];
  for (i = 1; i < N + 1; i++) S[i] = S[i - 1] + A[i - 1];
  sort(S.begin(), S.end());
  ans = 0;
  for (i = 0; i < N + 1; i++) {
    if (i == 0) {
      scount = 1;
    } else if (S[i] == S[i - 1]) {
      scount++;
    } else {
      ans += (scount * (scount - 1)) / 2;
      scount = 1;
    }
  }
  ans += (scount * (scount - 1)) / 2;
  cout << ans << '\n';
}
