#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
  long long N, A[200000];
  cin >> N;
  long long cs = 0;
  mp[0] = 1;
  for (int i = 1; i < N + 1; i++) {
    long long tmp;
    cin >> tmp;
    cs += tmp;
    mp[cs]++;
  }
  long long res = 0;
  for (auto& p : mp) {
    res += p.second * (p.second - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
