#include <bits/stdc++.h>
using namespace std;
int N;
const int MAX_N = 2.0e5 + 100;
long long A[MAX_N];
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  long long acc[N + 1];
  acc[0] = 0;
  for (int i = 0; i < N; i++) acc[i + 1] = acc[i] + A[i];
  map<int, long long> mp;
  for (int i = 0; i <= N; i++) {
    mp[acc[i]]++;
  }
  long long ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    long long val = itr->second;
    ans += val * (val - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
