program main use iso_fortran_env implicit none integer(int64)::N,M integer(int64)::i,cnt,tmp integer,allocatable,dimension(:)::A read*,N,M read*,A cnt=0;tmp=0 do i=1,N select case (mod(A(i),2)) case(0) if(cnt>=M)print"(i0)",tmp cnt=0;tmp=0 case(1) cnt=cnt+1 tmp=tmp+A(i) end select end do if(cnt>=M)print"(i0)",tmp end program main