#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() {
  freopen("in", "r", stdin);
  cin >> n;
  map<long long, int> mapa;
  mapa[0] = 1;
  long long ans = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    sum += x;
    ans += mapa[sum];
    ++mapa[sum];
  }
  cout << ans << '\n';
}
