#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fast();
  int n;
  cin >> n;
  long long a[n];
  map<long long, long long> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    a[i] += a[i - 1];
    m[a[i]]++;
  }
  long long sum = 0;
  for (auto i : m) {
    sum += (i.second * (i.second - 1));
  }
  cout << sum << "\n";
}
