#include <bits/stdc++.h>
using namespace std;
int main() {
  long res = 0;
  long N;
  cin >> N;
  long A[300000];
  for (int i = 1; i <= N; i++) cin >> A[i];
  long S[300000];
  S[0] = 0;
  for (int i = 1; i <= N; i++) S[i] = S[i - 1] + A[i];
  for (int i = 0; i <= N; i++)
    for (int j = i + 1; j <= N; j++)
      if (S[i] == S[j]) res++;
  cout << res << endl;
}
