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