#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> table;
  int n;
  cin >> n;
  vector<long long> sum(n + 1, 0);
  long long a;
  int s;
  for (int i = 0; i < (n); i++) {
    cin >> a;
    sum[i + 1] = sum[i] + a;
  }
  sort(sum.begin(), sum.end());
  int cou = 1, res = 0;
  for (int i = 1; i <= n; i++) {
    if (sum[i] == sum[i - 1]) {
      cou++;
    } else {
      res += (cou * cou - cou) / 2;
      cou = 1;
    }
  }
  res += (cou * cou - cou) / 2;
  cout << res << endl;
}
