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