SRM 511 DIV 2 250

Took lot of time silly code