#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<long long> B(N + 1);
  B[0] = 0;
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
    B[i + 1] = sum;
  }
  map<long long, int> mp;
  for (int i = 0; i < N + 1; i++) {
    mp[B[i]]++;
  }
  long long ans = 0;
  for (auto x : mp) {
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
}
