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