Medain in a running stream


please make me understand that why my code is not workng …!!and please correct me where i was wrong

@Gaurav_dev,
Your code fails here, please dry run to find the bug.

Input
1
3
1 2 3