#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long tmp;
  long long sum = 0;
  map<long long, int> a;
  a[0] = 1;
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    sum += tmp;
    a[sum]++;
  }
  long long res = 0;
  for (auto &e : a) {
    res += (e.second - 1) * e.second / 2;
  }
  cout << res << '\n';
  return 0;
}
