#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const long long int INF = 1e18;
int main() {
  int n;
  cin >> n;
  vector<long long int> a(n), b(n + 1, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) b[i + 1] = b[i] + a[i];
  sort(b.begin(), b.end());
  int cnt = 1, ans = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] == b[i + 1])
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
  return 0;
}
