#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
vector<int> V;
static const int MAX = (int)2e5;
static const int MOD = (int)1e9 + 7;
static const int NMAX = 50;
static const int MMAX = 50;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int tx[8] = {-1, 0, 1, -1, 1, -1, 0, 1},
          ty[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int N, ans;
long long a, S[MAX + 2];
void solve() {
  sort(S, S + N + 1);
  for (int i = S[0]; i <= S[N]; i++) {
    int cunt = upper_bound(S, S + N + 1, i) - lower_bound(S, S + N + 1, i);
    if (cunt <= 1) continue;
    ans += (cunt - 1) * cunt / 2;
  }
  cout << ans << "\n";
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  S[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> a;
    S[i] = S[i - 1] + a;
  }
  solve();
  return 0;
}
