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