#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<long long> arr(N + 1);
  for (int i = 0; i < N; i++) arr[i + 1] = arr[i] + A[i];
  map<long long, long long> m;
  m[0] = 0;
  int res = 0;
  for (int i = 0; i < N + 1; i++) {
    res += m[arr[i]];
    m[arr[i]]++;
  }
  cout << res << endl;
  return 0;
}
