Is it possible to make a formula for median that works with both even or odd amounts of values?

Everyone here probably knows the median formula. It's the middle number of the set if the number of values in the set is odd, or the average of the two middle numbers in the set if the number of values in the set is even. But, I've always been left wondering, Is it possible to make a formula for median that works with both even or odd amounts of values?

Any help would be appreciated.


For an ordered sequence $a_i$ defined for $0\leq i\leq n$, the median $\bar a$ of the sequence is given by:

$$\bar a=\frac{a_{\left\lfloor\frac{n}{2}\right\rfloor} +a_{\left\lceil\frac{n}{2}\right\rceil}}{2}$$