#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int INF = 1e9;
int main() {
  int N, a;
  cin >> N;
  vector<int> A(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> a;
    A[i] = A[i - 1] + a;
  }
  sort(A.begin(), A.end());
  ll ans = 0, cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (A[i] == A[i + 1]) {
      cnt++;
    } else {
      ans += cnt * (cnt + 1) / 2;
      cnt = 0;
    }
  }
  ans += cnt * (cnt + 1) / 2;
  cout << ans << endl;
  return 0;
}
