#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toStr(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1);
  for (int i = (0); i <= ((N)-1); ++i) {
    cin >> A[i + 1];
  }
  vector<int> S(N + 1, 0);
  for (int i = (1); i <= (N); ++i) {
    S[i] = S[i - 1] + A[i];
  }
  map<long long, long long> count;
  for (int i = (0); i <= (N); ++i) {
    count[S[i]]++;
  }
  int ans = 0;
  for (auto it = count.begin(); it != count.end(); ++it) {
    int p = it->second;
    ans += p * (p - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
