#include <bits/stdc++.h>
using namespace std;
long long M = 1000000007;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<long long> a(n), b(n + 1);
  map<long long, int> cnt;
  for (int i = 0; i < n; ++i) cin >> a[i];
  b[0] = 0;
  for (int i = 0; i < n; ++i) b[i + 1] = b[i] + a[i];
  for (int i = 0; i <= n; ++i) cnt[b[i]]++;
  long long res = 0;
  for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
    res += itr->second * (itr->second - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
