#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
long long sum[200005];
int a[200005];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  sort(sum, sum + n + 1);
  int cnt = 1;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (sum[i] == sum[i - 1]) {
      cnt++;
    } else {
      ans += (cnt - 1) * cnt / 2;
      cnt = 1;
    }
  }
  ans += (cnt - 1) * cnt / 2;
  cout << ans << endl;
  return 0;
}
