#include <bits/stdc++.h>
using namespace std;
using namespace std;
template <class T = long long>
T in() {
  T _in;
  cin >> _in;
  return (_in);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N = in();
  long long S[200001];
  S[0] = 0;
  S[1] = in();
  for (int i = 2; i < N + 1; i++) S[i] = S[i - 1] + in();
  sort(S, S + N + 1);
  int res = 0;
  for (int i = 0; i < (int)(N + 1); i++) {
    int count = 1;
    for (int j = i + 1; j < N + 1; j++) {
      if (S[j] == S[i])
        count++;
      else
        break;
    }
    if (count > 1) {
      res += count * (count - 1) / 2;
    }
    i += count - 1;
  }
  cout << res << endl;
  return 0;
}
