Given an integer array, construct a new array where res[i] is the product of all elements except arr[i] without using division.
Implement product_except_self(arr). Return an array of the same length. The solution should run in O(n) time and use O(1) auxiliary space, excluding the output array. Handle zero and negative values correctly.
def product_except_self(arr):