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