Pergunta de entrevista da empresa Kite Games Studio

Given an array of integers and two integers X and Y. Let a subarray called good if the minimum element of the subarray is equal to X and the maximum element of the subarray is equal to Y. Calculate the number of subarrays of the array.