Maharaj magic restricts Sri Lanka to 277-9