#include <bits/stdc++.h>
using namespace std;
int N;
long long A[200005];
long long A_sum[200005];
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  A_sum[0] = 0;
  for (int i = 1; i <= N; i++) {
    A_sum[i] = A_sum[i - 1] + A[i];
  }
  int ans = 0;
  map<long long, long long> mp;
  for (int i = 0; i <= N; i++) {
    ans += mp[A_sum[i]];
    mp[A_sum[i]]++;
  }
  cout << ans << endl;
}
