#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  vector<long> sum;
  for (int i = (0); i < (int)(n); i += 1) {
    int num;
    cin >> num;
    a.push_back(num);
  }
  sum.push_back(0);
  long total = 0;
  long minim = 0, maxim = 0;
  for (int i = (0); i < (int)(n); i += 1) {
    total += a[i];
    sum.push_back(total);
    minim = min(minim, total);
    maxim = max(maxim, total);
  }
  int cnt = 0;
  for (int i = (minim); i < (int)(maxim + 1); i += 1) {
    int tmpcnt = 0;
    for (int j = (0); j < (int)(n + 1); j += 1) {
      if (sum[j] == i) {
        tmpcnt++;
      }
    }
    cnt += tmpcnt * (tmpcnt - 1) / 2;
  }
  cout << cnt << endl;
  return 0;
}
