# Equivalent Python code for the same logic. import sys def solve(): # Read N and M from input line, split by space, convert to integers. N, M = map(int, sys.stdin.readline().split()) # Read the sequence A from input line, split by space, convert elements to integers. A = list(map(int, sys.stdin.readline().split())) # Variables to track the current block of odd numbers current_start_idx = -1 # Start index of the current block, -1 if not in a block current_sum = 0 # Sum of elements in the current block. Python ints handle large numbers automatically. # Iterate through the sequence using 0-based indices for i in range(N): # Check if A[i] is odd if A[i] % 2 != 0: # If this is the start of a new block if current_start_idx == -1: current_start_idx = i # Add to the running sum current_sum += A[i] else: # A[i] is even (including 0) # If we were inside a block of odds if current_start_idx != -1: # Block ended at index i-1. Calculate its length. # Length = (i-1) - current_start_idx + 1 = i - current_start_idx block_length = i - current_start_idx # Check if length is sufficient if block_length >= M: print(current_sum) # Reset state current_start_idx = -1 current_sum = 0 # If not inside a block, do nothing. # After loop, check if the last block extended to the end if current_start_idx != -1: # Block ends at N-1. Calculate its length. # Length = (N-1) - current_start_idx + 1 = N - current_start_idx block_length = N - current_start_idx # Check if length is sufficient if block_length >= M: print(current_sum) # Call the main function to run the solution solve()