#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << "\t";
  }
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}
const int MAX_N = (int)2 * 1e5;
int N;
int A[MAX_N], Asum[MAX_N + 1];
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (long long i = 0; i < (N); i++) {
    int t;
    cin >> t;
    A[i] = t;
  }
  long long sum = 0;
  map<long long, int> count;
  count[0]++;
  for (long long i = 0; i < (N); i++) {
    sum += A[i];
    Asum[i + 1] = sum;
    count[sum]++;
  }
  long long ans = 0;
  for (auto i : count) {
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
