#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int, int>, 4> fd{make_pair(1, 0), make_pair(-1, 0),
                                  make_pair(0, 1), make_pair(0, -1)};
int n;
int a[200001];
int com(int x) { return (x * (x - 1)) / 2; }
int main() {
  cin >> n;
  for (int i = (0); i < (n); i++) cin >> a[i];
  for (int i = (1); i < (n); i++) a[i] += a[i - 1];
  a[n] = 0;
  sort(a, a + n + 1);
  int ren = 0, past = a[0];
  long long ans = 0;
  for (int i = (0); i < (n + 1); i++) {
    if (a[i] == past) ren++;
    if (a[i] != past) {
      ans += com(ren);
      ren = 1;
      past = a[i];
    }
  }
  ans += com(ren);
  cout << ans << endl;
}
