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