#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
long long n, a[200010], ans = 0;
void solve() {
  cin >> n;
  a[0] = 0;
  for (int64_t i = (1); i < (n + 1); i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  sort(a, a + n + 1);
  int cnt = 1;
  for (int64_t i = (0); i < (n + 1); i++) {
    if (a[i] != a[i + 1]) {
      ans += cnt * (cnt - 1) / 2;
      cnt = 0;
    }
    cnt++;
  }
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
