import numpy as np

def median_index(arr):
    sorted_indices = np.argsort(arr)
    n = len(arr)
    mid = n // 2
    if n % 2 == 1:
        # Odd number of elements: return the index of the middle element
        return sorted_indices[mid]
    else:
        # Even number: choose either of the two middle values' indices
        # For example, choose the lower median
        return sorted_indices[mid - 1]
