import java.util.ArrayList;
public class Solution {
    public int[] multiply(int[] A) {
        int[] prefix = new int[A.length];
        int[] suffix = new int[A.length];
        prefix[0] = 1;
        suffix[suffix.length - 1] = 1;
        for (int i = 1; i < A.length; i++) {
            prefix[i] = prefix[i - 1] * A[i - 1];
        }
        for (int i = A.length - 2; i > -1; i--) {
            suffix[i] = suffix[i + 1] * A[i + 1];
        }
        int[] res = new int[A.length];
        for (int i = 0; i < A.length; i++) {
            res[i] = prefix[i] * suffix[i];
        }
        return res;
    }
}