#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int INF = 1e9;
const int MAX = 100001;
int Q;
int main() {
  cin >> Q;
  vector<int> a(Q, 0), s(Q + 1, 0);
  for (int i = 0; i < (Q); ++i) cin >> a[i];
  for (int i = 0; i < (Q); ++i) s[i + 1] = s[i] + a[i];
  map<int, int> m;
  for (int i = 0; i < (s.size()); ++i) ++m[s[i]];
  int ans = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    int num = itr->second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
}
