I want to construct a function
$$f(\{ x_n\}) = x_k $$
where $x_k$ is the median.
The function must be of the form
$$f(\{ x_n\}) = \sum_{k=1}^na_k x_k$$
Example
Suppose we want to find the median of $\{x_n\} = \{1,2,3,4,5\}$ then since it is ordered we have $\{a_n\} = \{0,0,1,0,0 \}$.
Question
What functions do we create to model this mathematically ?
Attempt
Let $\{ y_n\}$ be the sorted sequence of $\{x_n\}$.
$$y_1 = \mathrm{min}(\{ x_n\})$$ $$y_k = \mathrm{min}(\{x_{n} \}-\{y_{k-1}\})$$
Then the coefficients are given as
$$a_k= \begin{cases} 1 & \text{if $x_k=y_{n/2} \, \, $} \\ 0 & \text{otherwise} \end{cases} $$
You desire to express (originally, without "depending on comparisons") the median of $\{x_1,\ldots,x_n\}$ in the form of a summation:
$$ \sum_{k=1}^n a_k x_k $$
(Note the mistake in using index $n$ rather than $k$ in your Question.)
We must necessarily express each $a_k$ in terms of the $x_j$'s, since no choice of constant $a_k$ will work (the median is not a linear function of the $x_j$'s, unlike the mean, which is a linear function).
Where $n$ is a fixed number, we outline one way to express the $a_k$. One idea is that when $n$ is odd and all entries are distinct, we want a coefficient $a_k$ that is $1$ when there are both at least $n/2$ entries $x_j$ that are greater than or equal to $x_k$ as well as at least $n/2$ entries that are less than or equal to $x_k$, and otherwise $a_k=0$. The cases where $n$ is even or some entries can be equal can be handled through modifying this idea to count how many entries are candidates for the median and thereby take an average of them.
One way to disguise such comparisons as arithmetic computations is by using the $\operatorname{sign}(x)$ function, which in turn can be defined in terms of the absolute value function, given some assumption about the arguments $x_j$.