#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI = acos(-1);
int main() {
  int N;
  cin >> N;
  long long A[N], B[N];
  map<long long, long long> S;
  for (int i = 0; i < (N); i++) {
    int a;
    cin >> a;
    if (i == 0) {
      A[i] = a;
      B[i] = a;
      S[a]++;
    } else {
      A[i] = a;
      B[i] = B[i - 1] + a;
      S[B[i]]++;
    }
  }
  long long ans = 0;
  for (int i = 0; i < (N); i++) {
    long long a = B[i];
    S[a]--;
    long long tmp = B[i] - A[i];
    long long s = S[tmp];
    ans += s;
  }
  cout << ans << endl;
}
