Why is the Median Less Sensitive to Extreme Values Compared to the Mean? I am sure we have all heard the following argument stated in some way or the other:

*

*For a given set of measurements (e.g. heights of students), the mean of these measurements is more "prone" to be influenced by outliers compared to the median of these same measurements.
Conceptually, the above argument is straightforward to understand. The median is not directly calculated using the "value" of any of the measurements, but only using the "ranked position" of the measurements. On the other hand, the mean is directly calculated using the "values" of the measurements, and not by using the "ranked position" of the measurements. Therefore, a statistically larger number of outlier points should be required to influence the median of these measurements - compared to influence of fewer outlier points on the mean. For example: the average weight of a blue whale and 100 squirrels will be closer to the blue whale's weight, but the median weight of a blue whale and 100 squirrels will be closer to the squirrels.
Using the R programming language, we can see this argument manifest itself on simulated data:
library(plotly)
    set.seed(123)


d = data.frame(data = rnorm(20, 5,50), col = "non outlier")

dd = data.frame(data = rnorm(5,150, 10), col = "outlier")

my_data = rbind(d,dd)

> mean(d$data)
[1] 10.08877

> median(d$data)
[1] 17.11447

We can also plot this to get a better idea:
d1 = data.frame(data = mean(my_data$data), col = "mean")
# add "1" to the median so that it becomes visible in the plot
d2 = data.frame(data = median(my_data$data) +1 , col = "median")

new_data = rbind(my_data, d1, d2)


plot_ly(type = "scatter", mode = "markers", data = new_data, x = ~data, y = " ", color = ~col ) %>% layout(title = 'Effect of Outliers on Median vs Mean')


My Question:  In the above example, we can see that the median is less influenced by the outliers compared to the mean - but in general, are there any "statistical proofs" that shed light on this inherent "vulnerability" of the mean compared to the median?
Apart from the logical argument of measurement "values" vs. "ranked positions" of measurements - are there any theoretical arguments behind why the median requires larger valued and a larger number of outliers to be influenced towards the extremas of the data compared to the mean?
I am aware of related concepts such as Cooke's Distance (https://en.wikipedia.org/wiki/Cook%27s_distance) which can be used to estimate the effect of removing an individual data point on a regression model - but are there any formulas which show some relation between the number/values of outliers on the mean vs. the median?
Are there any theoretical statistical arguments that can be made to justify this logical argument regarding the number/values of outliers on the mean vs. the median?

Extreme values influence the tails of a distribution and the variance of the distribution. This also influences the mean of a sample taken from the distribution.
Extreme values do not influence the center portion of a distribution. This means that the median of a sample taken from a distribution is not influenced so much.

Example
Below is an illustration with a mixture of three normal distributions with different means.
The mixture is 90% a standard normal distribution making the large portion in the middle and two times 5% normal distributions with means at $+ \mu$ and $-\mu$.
The value of $\mu$ is varied giving distributions that mostly change in the tails.

The consequence of the different values of the extremes is that the distribution of the mean (right image) becomes a lot more variable.


For large sample sizes
The sample variance of the mean will relate to the variance of the population:
$$Var[mean(x_n)] \approx \frac{1}{n} Var[x]$$
The sample variance of the median will relate to the slope of the cumulative distribution (and the height of the distribution density near the median)
$$Var[median(x_n)] \approx  \frac{1}{n} \frac{1}{4f(median(x))^2}$$
Example where the mean is less influenced by outliers
In general we have that large outliers influence the variance $Var[x]$ a lot, but not so much the density at the median $f(median(x))$.
But, it is possible to construct an example where this is not the case. If we mix/add some percentage $\phi$ of outliers to a distribution with a variance of the outliers that is relative $v$ larger than the variance of the distribution (and consider that these outliers do not change the mean and median), then the new mean and variance will be approximately
$$Var[mean(x_n)] \approx \frac{1}{n}  (1-\phi + \phi v) Var[x]$$
$$Var[mean(x_n)] \approx \frac{1}{n}  \frac{1}{4((1-\phi)f(median(x))^2}$$
So the relative change (of the sample variance of the statistics) are for the mean $\delta_\mu = (v-1)\phi$ and for the median $\delta_m = \frac{2\phi-\phi^2}{(1-\phi)^2}$. And we have $\delta_m > \delta_\mu$ if $$v < 1+ \frac{2-\phi}{(1-\phi)^2}$$
An example here is a continuous uniform distribution with point masses at the end as 'outliers'. The variance of a continuous uniform distribution is 1/3 of the variance of a Bernoulli distribution with equal spread. So $v=3$ and for any small $\phi>0$ the condition is fulfilled and the median will be relatively more influenced than the mean.
This is a contrived example in which the variance of the outliers is relatively small. This is done by using a continuous uniform distribution with point masses at the ends. So the outliers are very tight and relatively close to the mean of the distribution (relative to the variance of the distribution).
