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