#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
long long a[maxn];
int main(int argc, char const *argv[]) {
  int n;
  a[0] = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  sort(a + 1, a + n + 1);
  long long sum = 0;
  int cnt = 1;
  for (int i = 1; i <= n; i++)
    if (a[i] == 0) sum++;
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[i - 1]) {
      cnt++;
      if (i == n) {
        cnt--;
        sum += cnt * (cnt + 1) / 2;
      }
    } else if (a[i] != a[i - 1]) {
      cnt--;
      sum += cnt * (cnt + 1) / 2;
      cnt = 1;
    }
  }
  printf("%lld\n", sum);
  return 0;
}
