#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
vector<int> vec;
unordered_map<long long, int> st;
int n;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (auto i = 0, x = 0; i < n; i++) {
    cin >> x;
    vec.push_back(x);
    if (i) vec[i] += vec[i - 1];
  }
  st[0]++;
  auto ans = 0ll;
  for (auto i : vec) {
    ans += st[i];
    st[i]++;
  }
  cout << ans << endl;
  return 0;
}
