#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
long long int n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
long long int powMOD(long long int a, long long int b) {
  long long int x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (x * a) % MOD;
    }
    a = (a * a) % MOD;
    b >>= 1;
  }
  return x;
}
long long int nCk(long long int a, long long int b) {
  long long int x = 1;
  for (long long int i = (long long int)(0); i < (long long int)(b); i++) {
    x *= (a - i);
    x %= MOD;
  }
  long long int y = 1;
  for (int i = b; i >= 2; i--) {
    y *= i;
    y %= MOD;
  }
  return (x * powMOD(y, MOD - 2) % MOD) % MOD;
}
map<long long int, long long int> mp;
int main() {
  cin >> n;
  vector<long long int> v(n), va;
  for (long long int i = (long long int)(0); i < (long long int)(n); i++) {
    cin >> v[i];
  }
  va.push_back(v[0]);
  for (long long int i = (long long int)(0); i < (long long int)(n - 1); i++) {
    va.push_back(va[i] + v[i + 1]);
  }
  for (long long int i = (long long int)(0); i < (long long int)(va.size());
       i++) {
    mp[va[i]]++;
  }
  mp[sum]++;
  for (auto x : mp) {
    if (x.second >= 2) {
      cnt += nCk(x.second, 2);
    }
  }
  cout << cnt << endl;
}
