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