#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9 + 7;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int a;
  vector<int> cum(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a;
    cum[i] = cum[i - 1] + a;
  }
  map<int, int> cnt;
  for (int i = 0; i <= n; ++i) {
    ++cnt[cum[i]];
  }
  map<int, bool> exist;
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (exist[cum[i]]) continue;
    exist[cum[i]] = true;
    ans += (cnt[cum[i]] - 1) * cnt[cum[i]] / 2;
  }
  cout << ans << "\n";
  return 0;
}
