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