#include <bits/stdc++.h>
using namespace std;
long long a[200001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i > 0) a[i] += a[i - 1];
  }
  long long ans = 0;
  for (int i = 0; i < n + 1; ++i) {
    ans += count(a + i + 1, a + n + 1, a[i]);
  }
  cout << ans << endl;
}
