#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int a, sum = 0, N;
  cin >> N;
  map<int, int> x;
  long long count = 0;
  for (int i = 0; i < N; i++) cin >> a, x[sum += a]++;
  for (auto p : x) {
    long long n = p.second;
    if (p.first == 0) count += p.second;
    if (n > 1) n *= n - 1, n /= 2, count += n;
  }
  cout << count;
}
