#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> m;
  m[0] = 1;
  int res = 0, s = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    s += x, res += m[s], m[s] += 1;
  }
  cout << res << "\n";
}
