#include <bits/stdc++.h>
using namespace std;
int n, a;
map<int, int> mp;
long long res;
int main() {
  cin >> n;
  mp[0] = 1;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a += x;
    mp[a]++;
  }
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    int s = it->second;
    res += s * (s - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
