#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();
long nCr(int n, int r) {
  long ans = 1;
  for (int i = n; i > n - r; --i) {
    ans = ans * i;
  }
  for (int i = 1; i < r + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}
void solve() {
  int N;
  cin >> N;
  int a[2 * 100000 + 5], sum[2 * 100000 + 5];
  for (int i = 0; i < int(N); ++i) cin >> a[i];
  int s = 0;
  for (int i = 0; i < int(N); ++i) {
    s += a[i];
    sum[i] = s;
  }
  map<int, int> mm;
  for (int i = 0; i < int(N); ++i) {
    mm[sum[i]]++;
  }
  int ans = mm[0];
  for (auto t : mm) {
    int i = t.second;
    if (i >= 2) ans += nCr(i, 2);
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
