#include<stdio.h>

void array_multiplication(int A[], int OUTPUT[], int n)
{
	// Initializing left and right
	int left = 1;
	int right = 1;
	
	// Initialize the output array
	int i = 0;
	for (i = 0; i < n; i++)
		OUTPUT[i] = 1;	

	for (i = 0; i < n; i++)
	{
		// Code obtained from http://w...content-available-to-author-only...s.com
		// Feel free to copy but please acknowledge if possible
		OUTPUT[i] *= left;
		OUTPUT[n - 1 - i] *= right;
		
		// The variable left stores the multiplication of
		// all elements on the left
		left *= A[i];
		
		// The variable right stores the multiplication of
		// all elements on the right
		right *= A[n - 1 - i];
	}
}

int main(void)
{
	
	int arr[] = {4, 3, 2, 1, 2};
	
	int OUTPUT[5] = {0};
	
	array_multiplication(arr, OUTPUT, 5);
	
	int i = 0;
	for(i=0; i<5; i++)
		printf("%d ",OUTPUT[i]);
	
	return 0;
}