#include <bits/stdc++.h>
using namespace std;
const size_t MAX_N = 2e5 + 5;
int a[MAX_N], sum[MAX_N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    sum[i] = sum[i - 1] + a[i];
  }
  map<int, int> mp;
  mp[0] = 1;
  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    res += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << res << '\n';
  return 0;
}
