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