Help me in solving DSCPPAS277 problem

My issue

the code is showing error of failed on a hidden tese

My code

def longest_ones_after_flip(arr):
    n = len(arr)

    left = 0
    zero_count = 0
    max_length = 0

    for right in range(n):
        # Count the zeros in the current window
        if arr[right] == 0:
            zero_count += 1
        
        # If there are more than one zero in the window, move the left pointer
        while zero_count > 1:
            if arr[left] == 0:
                zero_count -= 1
            left += 1

        # Calculate the length of the current window
        # The window is valid and can be flipped if we have at most one `0` in it
        max_length = max(max_length, right - left + 1)

    return max_length

# Input handling
if __name__ == "__main__":
    n = int(input())
    arr = list(map(int, input().split()))
    # Output the result
    print(longest_ones_after_flip(arr))

Learning course: Design and analysis of Algorithms
Problem Link: https://www.codechef.com/learn/course/abesit-daa/ABESITDA31/problems/DSCPPAS277