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