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