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