This question evaluates algorithmic problem-solving skills, including core algorithm implementation, handling a consecutive-N-element constraint, and designing an optimization that leverages suffix-related information.

Pure programming problem solving: implement the core algorithmic solution, then extend it to (