#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long A;
  long long sum = 0;
  map<long long, int> mp;
  for (int i = 0; i < N; i++) {
    cin >> A;
    sum += A;
    if (mp.count(sum) == 0) {
      mp[sum] = 1;
    } else {
      mp[sum] += 1;
    }
  }
  long long ret = 0;
  for (auto x : mp) {
    if (x.first == 0) ret += x.second;
    ret += x.second * (x.second - 1) / 2;
  }
  cout << ret << endl;
  return 0;
}
