#include <bits/stdc++.h>
using namespace std;
class data {
 public:
  long long val;
  int num;
  data(long long _val, int _num) {
    val = _val;
    num = _num;
  }
};
long long sum = 0;
bool find_func(data d) { return d.val == sum; }
int main() {
  int N;
  cin >> N;
  vector<data> A;
  A.push_back(data(0, 1));
  int ret = 0;
  for (int i = 0; i < N; i++) {
    long long in;
    cin >> in;
    sum += in;
    vector<data>::iterator it;
    if ((it = find_if(A.begin(), A.end(), find_func)) != A.end()) {
      ret += (*it).num;
      (*it).num++;
    } else {
      A.push_back(data(sum, 1));
    }
  }
  cout << ret << endl;
  return 0;
}
