#include <bits/stdc++.h>
using namespace std;
long long sum[200005];
int countPairs(long long arr[], int n) {
  int cnt = 0;
  for (int i = 1; i <= n;) {
    int up = upper_bound(arr + i, arr + n + 1, arr[i]) - arr;
    cnt = cnt + (up - i) * (up - i - 1) / 2;
    if (arr[i] == 0) cnt += (up - i);
    i = up;
  }
  return cnt;
}
int main() {
  int n = 0;
  memset(sum, 0, sizeof(sum));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long num = 0;
    cin >> num;
    sum[i] = sum[i - 1] + num;
  }
  sort(sum + 1, sum + n + 1);
  cout << countPairs(sum, n);
  return 0;
}
