Array Reduction 1 Hackerrank Problem Solution