M Arrays Hackerrank Solution Python