SRM 619. div2-500. Submitted for 312 points