#include <bits/stdc++.h>
using namespace std;
long long dx[8] = {0, 1, 1, 1, 0, -1, -1, -1},
          dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
template <class T>
inline bool maxi(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool mini(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int mxn = 200001;
int n, in[mxn], ctr = 1, ans = 0;
vector<int> sum(1, 0);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = (0), i_len = (n); i < i_len; ++i) {
    cin >> in[i];
    sum.push_back(sum[i] + in[i]);
  }
  sort((sum).begin(), (sum).end());
  for (int i = (1), i_len = (n); i <= i_len; ++i) {
    if (sum[i] == sum[i - 1]) {
      ctr++;
    } else {
      ans += ctr * (ctr - 1) / 2;
      ctr = 1;
    }
  }
  ans += ctr * (ctr - 1) / 2;
  cout << (ans) << "\n";
  1;
}
