#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  map<int, int> ma;
  ma[0]++;
  int sum = 0;
  for (int i = 0; i < (int)(N); i++) {
    int a;
    cin >> a;
    sum += a;
    ma[sum]++;
  }
  long long res = 0;
  for (auto itr = ma.begin(); itr != ma.end(); itr++) {
    int n = itr->second;
    res += n * (n - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
