#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<int> a(n);
  map<long long, long long> ans;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i != 0) a[i] += a[i - 1];
    ans[a[i]]++;
  }
  long long sum = 0;
  for (auto it : ans) {
    if (it.second >= 2) sum += ((it.second - 1) * it.second) / 2;
  }
  cout << sum + ans[0] << endl;
}
