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