#include <bits/stdc++.h>
using namespace std;
int n;
long long int a[200000];
int answer;
int main() {
  cin >> n;
  vector<long long int> sum(n + 1, 0);
  answer = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i - 1];
  }
  sort(sum.begin(), sum.end());
  int num = 0;
  for (int i = 0; i < n; i++) {
    if (sum[i] == sum[i + 1])
      ++num;
    else {
      answer += num * (num + 1) / 2;
      num = 0;
    }
  }
  answer += num * (num + 1) / 2;
  cout << answer << endl;
}
