#include int main() { int i, N, A[100001]; scanf("%d", &N); for (i = 1; i <= N; i++) scanf("%d", &(A[i])); int k, sum, num[6000001]; long long ans = (long long)N * (N - 1) / 2 + 1; for (k = 1; k <= 30; k++) { for (i = 0; i <= N * 60; i++) num[i] = 0; for (i = 1, sum = 0, num[N*30] = 1; i <= N; i++) { if (A[i] == k) ans -= num[sum + N * 30] - 1; sum += A[i] - k; num[sum + N * 30]++; } } printf("%lld\n", ans); fflush(stdout); return 0; }