#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  cin >> n;
  map<long, long> t;
  long s = 0, count = 0;
  count += t[s];
  t[s]++;
  for (int i = 0; i < n; i++) {
    int cache;
    cin >> cache;
    s += cache;
    count += t[s];
    t[s]++;
  }
  cout << count << endl;
}
