#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];
  }
  int c, i;
  c = 0;
  h[0] = a[0];
  mp[0] = 1;
  mp[a[0]] = 1;
  for (i = 1; i < n; ++i) {
    h[i] = h[i - 1] + a[i];
    mp[h[i]]++;
  }
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    int v = itr->second;
    { c += v * (v - 1) / 2; }
  }
  cout << c;
}
