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