#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int sum = 0, x, a[200001];
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    sum += x;
    a[i] = sum;
  }
  sort(a, a + n + 1);
  long long int ans = 0;
  int count = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == a[i - 1])
      count++;
    else {
      ans += count * (count - 1) / 2;
      count = 1;
    }
  }
  ans += count * (count - 1) / 2;
  cout << ans << endl;
}
