#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const double dinf = 12345678;
const int MOD = 1000000007;
const int maxn = 2e5 + 10;
int n, sum[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(20);
  cin >> n;
  int ans = 0;
  map<long long, int> mapa;
  mapa[0] = 1;
  cin >> sum[0];
  mapa[sum[0]] = 1;
  for (int i = 1; i < n; i++) {
    int x;
    cin >> x;
    sum[i] = sum[i - 1] + x;
    ans += mapa[sum[i]]++;
  }
  cout << ans << '\n';
  return 0;
}
