human
Count Inversions of size three in a given array | Returns count of inversions of size 3.
Initialize result.
Count all smaller elements on right of arr [ i ].
Count all greater elements on left of arr [ i ].
Update inversion count by adding all inversions that have arr [ i ] as middle of three elements.
Driver program to test above function"
Solution in Python:

=====
What is a code to count Inversions of size three in a given array and the other steps required?
assistant
#Here is code to count Inversions of size three in a given array and the other steps required.
 def getInvCount ( arr , n ) :
	invcount = 0
	for i in range ( 1 , n - 1 ) :
		small = 0
		for j in range ( i + 1 , n ) :
			if ( arr [ i ] > arr [ j ] ) :
				small += 1
		great = 0 ;
		for j in range ( i - 1 , - 1 , - 1 ) :
			if ( arr [ i ] < arr [ j ] ) :
				great += 1
		invcount += great * small
	return invcount
arr = [ 8 , 4 , 2 , 1 ]
n = len ( arr )
print ( " Inversion ▁ Count ▁ : " , getInvCount ( arr , n ) )