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