#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  int sum[200001] = {};
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    sum[i + 1] = sum[i] + k;
  }
  sort(sum, sum + n + 1);
  long int b[200001] = {};
  int t = 0, now = sum[0];
  b[0] = 1;
  for (int i = 1; i < n + 1; i++) {
    if (sum[i] == now) {
      b[t]++;
    } else {
      t++;
      b[t]++;
    }
    now = sum[i];
  }
  long int ans = 0;
  for (int i = 0; i < t + 1; i++) {
    ans += (b[i] - 1) * b[i] / 2;
  }
  cout << ans << endl;
}
