#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[N];
  int res = 0;
  for (int i = 0; i < N; ++i) cin >> a[i];
  int ruiseki[N + 1];
  ruiseki[0] = 0;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
    ruiseki[i + 1] = sum;
  }
  sort(ruiseki, ruiseki + N + 1000, greater<int>());
  int same = 1;
  for (int i = 1; i < N + 1; i++) {
    int a = ruiseki[i];
    int b = ruiseki[i - 1];
    if (a == b) {
      same++;
    } else {
      res += (same * (same - 1)) / 2;
      same = 1;
    }
  }
  res += (same * (same - 1)) / 2;
  cout << res << endl;
}
