#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long int a[212345];
  long long int h[212345];
  map<long long int, int> mp;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long int c, i;
  c = 0;
  h[0] = 0;
  mp[0] = 1;
  for (i = 0; i < n; ++i) {
    h[i + 1] = h[i] + a[i];
    mp[h[i + 1]]++;
  }
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    int v = itr->second;
    c += v * (v - 1) / 2;
  }
  cout << c;
}
