stay in the same value of analog input give output one time

Oh, then change the ELSE statement to print whatever you want it to say.

"else flagged =0;" change this to,

else { Serial.println("not valid");
         flagged =0;
       }