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