#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
  }
  vector<int> s(N + 1), r(N + 1);
  s[0] = 0;
  for (int i = 0; i < N; ++i) {
    s[i + 1] = s[i] + v[i];
  }
  int c = 0;
  map<int, int> m;
  for (int i = 0; i < N + 1; ++i) {
    m[s[i]] = m[s[i]] + 1;
  }
  for (auto x : m) {
    c += (x.second) * (x.second - 1) / 2;
  }
  cout << c;
  return 0;
}
