#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long plas[n + 2];
  plas[0] = 0L;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> sum;
    plas[i + 1] = plas[i] + sum;
  }
  map<int, int> a{};
  long ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += a[plas[i]];
    a[plas[i]]++;
  }
  cout << ans << endl;
}
