#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5000;
const int mod = 1e9 + 7;
const int inf = 1e9;
int ch, pre[M];
bool vis[M];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &ch), pre[i] = pre[i - 1] + ch;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (pre[i] == 0) ans++;
    for (int j = i + 1; j <= n; j++) {
      if (pre[i] == pre[j]) {
        ans++;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
