def interpolation_search(arr, x):
    low = 0
    high = len(arr) - 1

    while low <= high and arr[low] <= x <= arr[high]:
        if arr[high] == arr[low]:
            return low if arr[low] == x else -1

        pos = low + (x - arr[low]) * (high - low) // (arr[high] - arr[low])

        if arr[pos] == x:
            return pos
        elif arr[pos] < x:
            low = pos + 1
        else:
            high = pos - 1

    return -1

# Example usage:
arr = [10, 20, 30, 40, 50, 60, 70]
x = 50
result = interpolation_search(arr, x)
if result != -1:
    print(f"Found {x} at index: {result}")
else:
    print("Number not found.")
# your code goes here