#include <bits/stdc++.h>
using namespace std;
const int INF = 0x2aaaaaaa;
const long long INFLL = 0x1f1f1f1f1f1f1f1fLL;
template <class A, class B>
inline ostream& operator<<(ostream& st, const pair<A, B>& P) {
  return st << "(" << P.first << "," << P.second << ")";
};
template <class A, class B>
inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) {
  return pair<A, B>(P.first + Q.first, P.second + Q.second);
};
template <class A, class B>
inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) {
  return pair<A, B>(P.first - Q.first, P.second - Q.second);
};
int main() {
  int n;
  cin >> n;
  map<long long, int> c;
  c[0] = 1;
  long long s = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    s += a;
    ++c[s];
  }
  long long ret = 0;
  for (auto& p : c) {
    ret += p.second * (p.second - 1) / 2;
  }
  cout << ret << endl;
}
