#include <bits/stdc++.h>
using namespace std;
const unsigned long long BIGEST = 1000000000000000000 + 1000000000000000000;
const long long BIGER = 1000000000000000000;
const int BIG = 1000000000;
const int MOD = 19260817;
int a[200001];
long long s[200001];
map<long long, int> mp;
int n;
int main() {
  scanf("%d", &n);
  int g;
  mp[0] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1] + a[i];
    g += mp[s[i]];
    mp[s[i]]++;
  }
  printf("%d", g);
  return 0;
}
