#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<long long> As(N);
  for (int n = 0; n < (int)(N); ++n) cin >> As[n];
  vector<long long> table(N + 1);
  map<long long, long long> seen;
  seen[0] = 1;
  int ans = 0;
  for (int n = 0; n < (int)(N); ++n) {
    table[n + 1] = table[n] + As[n];
    ans += seen[table[n + 1]];
    seen[table[n + 1]]++;
  }
  cout << ans << endl;
  return 0;
}
