#include <bits/stdc++.h>

using namespace std;

int n;

int main()
{
  cin >> n;

  map<int64_t, int> accum;
  accum[0] = 1;

  int64_t sum = 0;
  int64_t count = 0;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    sum += a;
    count += accum[sum];
    accum[sum]++;
  }

  cout << count << endl;

  return 0;
}
