#include <bits/stdc++.h>
int main(void) {
  int N, i, j;
  scanf("%d", &N);
  int A[N];
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  int count = 0;
  int dp[N + 1][N + 1];
  memset(dp, 0, sizeof(dp));
  for (i = 0; i < N; i++) {
    dp[i][0] = A[i];
    for (j = 1; j < N - i; j++) {
      dp[i][j] = dp[i][j - 1] + A[i + j];
      if (dp[i][j] == 0) count++;
    }
  }
  printf("%d", count);
}
