#include <bits/stdc++.h>
using namespace std;
int sum[200010], num[200010], ans, n, a[200010];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (sum[i] == 0) ans++;
    if (num[sum[i]] == 0) {
      num[sum[i]]++;
    } else {
      ans += num[sum[i]];
      num[sum[i]]++;
    }
  }
  cout << ans << endl;
}
