#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long A[200010];
vector<long long> S;
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  int ans = 0, sum = 0;
  S.push_back(0);
  for (int i = 0; i < N; i++) {
    sum += A[i];
    S.push_back(sum);
  }
  sort(S.begin(), S.end());
  int cnt = 0;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S[i] == S[i + 1]) {
      cnt++;
    } else {
      ans += (cnt * (cnt + 1)) / 2;
      cnt = 0;
    }
  }
  ans += (cnt * (cnt + 1)) / 2;
  cout << ans << endl;
}
