#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;
}
vector<long long> A;
vector<long long> S;
long long solve(const int N) {
  long long res = 0;
  int i = 0;
  for (; i < (int)S.size() - 1;) {
    int j = i + 1;
    for (; S[j] == S[i]; j++) {
    }
    res += long(j - i) * long(j - i - 1) / 2LL;
    i = j;
  }
  return res;
}
int main(void) {
  int N;
  cin >> N;
  A.resize(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  S.resize(N + 1);
  S[0] = 0;
  for (int i = 1; i <= N; i++) {
    S[i] = S[i - 1] + A[i];
  }
  sort(S.begin(), S.end());
  cout << solve(N) << endl;
  return 0;
}
