Array Mathematics Hackerrank Solution Python