#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N + 1, 0);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) B[i + 1] = A[i] + B[i];
  map<int, int> cnt;
  long long int ans = 0;
  for (int i = 0; i <= N; i++) {
    ans += cnt[B[i]];
    cnt[B[i]]++;
  }
  cout << ans << endl;
}
