SRM 322 div2-1000. Submitted for 501 points.