#include <bits/stdc++.h>
using namespace std;
inline void logger() { std::cout << " [LOGGER] " << endl; }
template <typename A, typename... B>
void logger(const A& a, const B&... b) {
  cout << a << " , ";
  logger(b...);
}
const long long MOD = 1000000007;
const long long MOD9 = 998244353;
const long long INF = MOD * MOD;
const int MAX = 200005;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int(i) = 0; (i) < (n); (i)++) cin >> a[i];
  for (int(i) = 0; (i) < (n - 1); (i)++) a[i + 1] += a[i];
  a.push_back(0);
  sort((a).begin(), (a).end());
  long long s = 1, t = 0, r = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    if (a[i + 1] == t)
      s++;
    else {
      r += s * (s - 1) / 2;
      s = 1;
      t = a[i + 1];
    }
  }
  cout << (r + s * (s - 1) / 2) << endl;
}
