#include <bits/stdc++.h>
using namespace std;
const int maxn = 200500;
int a[maxn];
long long p[maxn];
map<int, int> how;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  p[0] = 0;
  how[0] = 1;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    p[i + 1] = p[i] + a[i];
    ans += how[p[i + 1]];
    how[p[i + 1]]++;
  }
  cout << ans;
  return 0;
}
