#include <bits/stdc++.h>
using namespace std;
map<long long, int> val;
int main() {
  int n;
  cin >> n;
  int in;
  long long p(0);
  val[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> in;
    p += in;
    val[p]++;
  }
  int rez(0);
  for (map<long long, int>::iterator it = val.begin(); it != val.end(); it++) {
    rez += ((*it).second - 1) * ((*it).second) / 2;
  }
  cout << rez;
}
