#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[210000], pre[210000];
struct point {
  long long p, w;
} b[210000];
bool cmp(point a, point b) { return a.w < b.w; }
long long bSearch(long long e, long long p) {
  long long mid, left = 1, right = n;
  long long cnt = 0;
  while (left <= right) {
    mid = (left + right) >> 1;
    if (b[mid].w > e)
      right = mid - 1;
    else
      left = mid + 1;
  }
  for (long long i = right; i >= 1; i--) {
    if (b[i].w != e)
      break;
    else if (b[i].p > p)
      cnt++;
  }
  for (long long i = right + 1; i <= n; i++) {
    if (b[i].w != e)
      break;
    else if (b[i].p > p)
      cnt++;
  }
  return cnt;
}
int main() {
  cin >> n;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    pre[i] = pre[i - 1] + a[i];
  }
  b[0].w = 0;
  for (long long i = 1; i <= n; i++) {
    b[i].p = i;
    b[i].w = pre[i];
  }
  sort(b + 1, b + n + 1, cmp);
  for (long long i = 1; i <= n; i++) {
    ans += bSearch(pre[i - 1], i);
  }
  cout << ans << endl;
  return 0;
}
