#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n + 1, 0);
  for (int i = 0; i < (n); i++) cin >> a[i + 1];
  for (int i = 0; i < (n); i++) a[i + 1] += a[i];
  map<long long, long long> b;
  for (int i = 0; i < (n); i++) b[a[i + 1]]++;
  long long res = 0;
  for (auto it : b) {
    long long num = it.second;
    res += num * (num - 1) / 2;
  }
  cout << res << endl;
}
