#include <bits/stdc++.h>
using namespace std;
int N;
long long A[200001];
long long S[200001];
long long dp[200001];
map<long long, long long> m;
int main() {
  cin >> N;
  for (int i = 0; i < (N); i++) {
    cin >> A[i];
    if (i != 0) {
      S[i] = A[i] + S[i - 1];
    } else {
      S[i] = A[i];
    }
  }
  for (int i = 0; i < (N); i++) {
    dp[i] = 0;
  }
  for (int i = 0; i < (N); i++) {
    if (A[i] == 0) {
      if (i == 0) {
        dp[i] = 1;
      } else {
        dp[i] = dp[i - 1] + 1;
      }
      continue;
    }
    if (m.count(S[i]) != 0) {
      dp[i] = dp[m[S[i]]] + 1;
    } else if (S[i] == 0) {
      dp[i] = 1;
    }
    m[S[i]] = i;
  }
  long long ans = 0;
  for (int i = 0; i < (N); i++) {
    ans += dp[i];
  }
  cout << ans << endl;
  return (0);
}
