#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = {1, 0, -1, 0}, dj[4] = {0, 1, 0, -1};
int n, a[200010], s[200010], ans;
map<ll, int> mp;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }
  for (int i = 0; i <= n; i++) {
    ans += mp[s[i]];
    mp[s[i]]++;
  }
  cout << ans << endl;
  return 0;
}
