#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 4;
int n, a[N], res;
map<long long, int> Map;
long long Sum;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  Map[0] = 1;
  for (int i = 1; i <= n; ++i) {
    Sum += 1LL * a[i];
    res += Map[Sum];
    Map[Sum]++;
  }
  cout << res;
  return 0;
}
