#include <bits/stdc++.h>
using namespace std;
long long SUM, sum[100050], n, a[100050];
map<long long, bool> vis;
map<long long, int> dis;
int main() {
  SUM = 0;
  dis.clear();
  vis.clear();
  memset(sum, 0, sizeof(sum));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = sum[i - 1] + a[i];
    if (vis[sum[i]] == 0) {
      vis[sum[i]] = 1;
      dis[sum[i]]++;
    } else
      dis[sum[i]]++;
  }
  for (int i = n; i >= 1; i--) {
    if (sum[i] == 0) SUM++;
    if (vis[sum[i]] == 1 && dis[sum[i]] > 1) {
      SUM += (dis[sum[i]] - 1);
      dis[sum[i]]--;
    }
  }
  printf("%lld\n", SUM);
}
