#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long a[maxn], sum[maxn];
map<long long, int> vis;
map<long long, int> exist;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i];
    exist[sum[i]]++;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (sum[i] == 0) {
      cnt++;
    }
    if (!vis[sum[i]]) {
      vis[sum[i]] = 1;
      cnt += exist[sum[i]] * (exist[sum[i]] - 1) / 2;
    }
  }
  cout << cnt << endl;
  return 0;
}
