#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, a[N];
map<long long, int> t;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long ans = 0;
  t[0] = 1;
  for (int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
    ans += t[a[i]];
    t[a[i]]++;
  }
  cout << ans << endl;
  return 0;
}
