#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
map<int, int> psums;
i64 ant;
int n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int t, s;
  cin >> n;
  s = 0;
  psums[0] = 1;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    s += t;
    ant += psums[s];
    psums[s] += 1;
  }
  cout << ant << endl;
  return 0;
}
