#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
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;
}
class CumulativeSum {
 public:
  vector<long long> sum;
  CumulativeSum(vector<long long>& A) {
    for (int i = 0; i < A.size(); i++) {
      sum[i + 1] = sum[i] + A[i];
    }
  };
  long long getvalue(int l, int r) { return sum[r] - sum[l]; }
};
map<long long, int> cnt;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  CumulativeSum cs(A);
  long long ans = 0;
  for (int i = 0; i < N + 1; i++) {
    ans += cnt[cs.getvalue(0, i)];
    cnt[cs.getvalue(0, i)]++;
  }
  cout << ans << endl;
  return 0;
}
