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