#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int num[n + 1];
  num[n] = 0;
  cin >> num[0];
  for (int i = 1; i < n; ++i) {
    int t;
    cin >> t;
    num[i] = num[i - 1] + t;
  }
  sort(num, num + n + 1);
  long long ans = 0;
  for (int j = 0; j < n; ++j) {
    if (num[j] == num[j + 1]) {
      int t = 1;
      while (num[j] == num[j + 1] && j < n) {
        t++;
        j++;
      }
      ans += t * (t - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
