#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num[200005], sum[200005];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> num[i];
  sum[0] = num[0];
  for (int i = 1; i < n; i++) sum[i] = num[i] + sum[i - 1];
  int ans = 0;
  sort(sum, sum + n);
  for (int i = 0; i < n;) {
    int t = sum[i], m = 1;
    while (sum[++i] == t) m++;
    ans += m * (m - 1) / 2;
    if (t == 0) ans += m;
  }
  cout << ans << endl;
  return 0;
}
