#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int nCrModp(long long int n, long long int r, long long int p) {
  long long int C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}
int main() {
  long long int N;
  cin >> N;
  vector<long long int> A(N);
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  vector<long long int> B(N);
  B[0] = A[0];
  for (long long int i = 1; i < N; i++) B[i] = B[i - 1] + A[i];
  map<long long int, long long int> mp;
  mp[0]++;
  for (int i = 0; i < (int)(B.size()); i++) {
    mp[B[i]]++;
  }
  long long int cnt = 0;
  for (pair<long long int, long long int> p : mp) {
    if (p.second > 1) {
      cnt += nCrModp(p.second, 2, 1000000007);
    }
  }
  cout << cnt << endl;
  return 0;
}
