#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI = acos(-1);
int main() {
  int N;
  cin >> N;
  long long A[N + 1];
  map<int, int> S;
  for (int i = 0; i < (N + 1); i++) {
    int a;
    if (i == 0) {
      A[i] = 0;
      S[0]++;
    } else {
      cin >> a;
      A[i] = A[i - 1] + a;
      S[A[i]]++;
    }
  }
  long long ans = 0;
  for (int i = 0; i < (N); i++) {
    int a = A[i];
    S[a]--;
    ans += S[a];
  }
  cout << ans << endl;
}
