#include <bits/stdc++.h>
using namespace std;
int n, a[200010], b[200010], q = 1, g;
long long int xx, sm = 0;
vector<int> s;
int main() {
  scanf("%d", &n);
  b[0] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i + 1] = b[i] + a[i];
  }
  sort(b, b + n + 1);
  g = b[0];
  for (int i = 1; i <= n; i++) {
    if (g == b[i])
      q++;
    else {
      g = b[i];
      s.push_back(q);
      q = 1;
    }
  }
  s.push_back(q);
  for (int itr : s) {
    xx = 0;
    for (int i = 1; i < itr; i++) {
      xx += i;
    }
    sm += xx;
  }
  printf("%lld\n", sm);
}
