#include <bits/stdc++.h>
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
using ll = long long;
using namespace std;
int main() {
  int n;
  long long a[210000] = {};
  cin >> n;
  vector<ll> b(1, 0);
  int p = 1;
  int ans = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) b.push_back(b[i - 1] + a[i - 1]);
  sort(b.begin(), b.end());
  for (int i = 0; i < n; i++) {
    while (b[i] == b[i + 1]) {
      p++;
      i++;
    }
    ans += p * (p - 1) / 2;
    p = 1;
  }
  cout << ans << endl;
}
