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