#include <bits/stdc++.h>
using namespace std;
bool debug = true;
map<int, int> mp;
int n;
int a[200005];
int main(int argc, char* argv[]) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  mp[0] = 1;
  int sm = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    sm += a[i];
    ans += mp[sm];
    mp[sm]++;
  }
  cout << ans;
  return 0;
}
