Can median be expressed using linear combinations and max? The median of two numbers is their mean, $(a+b)/2$, the median of three numbers is their sum less their maximum and minimum, i.e.
$$Median(a,b,c) =  a + b + c - \max(a,\max(b,c)) - \min(a,\min(b,c)) $$
$$ = a + b + c - \max(a,\max(b,c)) + \max(-a,\max(-b,-c)) $$
and the median of 4 numbers proceeds similarly (since it's the mean of the center two,
$$Median(a,b,c,d) =  \frac{a + b + c + d - \max(\max(a,b),\max(c,d)) - \min(\min(a,b),\min(c,d))}{2} $$
$$ = \frac{a + b + c + d - \max(\max(a,b),\max(c,d)) + \max(\max(-a,-b),\max(-c,-d))}{2} $$
But is there any similar expression for 5 elements? If there are, bonus points for proof of minimality of your expression (by whatever metric you care), or generalizations to larger sets of elements, of course!  
(Background, if anyone is curious: This question was prompted by some machine learning code, where max/min are standard reduction functions, but medians are not; and when considering an ensemble of 5 models -- a pretty common number -- this would be useful. But this question seemed mathematically interesting on its own.)
 A: Here's a silly way of extracting the $k$th-largest element from $n$ numbers using only max and min. Let $[n]$ denote the set $\{1, \ldots, n\}$, then the $k$-th largest element of $\{a_1, \ldots, a_n\}$ is
$$ \min_{\substack{I \subseteq [n] \\ |I| = n - k + 1}} \max_{i \in I} a_i$$
In the example with $5$ elements, to find the largest element, the formula gives
$$\min(\max(a, b, c, d, e)) = \max(a, b, c, d, e)$$
while to find the second largest element, the formula gives
$$\min(\max(b, c, d, e), \max(a, c, d, e), \max(a, b, d, e), \max(a, b, c, e), \max(a, b, c, d))$$
The reason this works is that one of the five must be the maximum, and will appear in all but one $\max(\cdots)$ expression: the $\min$ operation finds this expression. You can then plug this into similar expressions that you had above.
I make no claims as to the minimality of this formula, and it would be pretty outrageous to use this for large sets. But for $n=5$ it might hit the spot.
A: The median-of-5 can be calculated from two chained median-of-3s:
med(a, b, c, d, e) = med(med(max(a, e), min(b, d), c), min(a, e), max(b, d))
"Proof": Try to get a large result with any two large inputs and three small inputs. Not possible.
