The inverse p-median problem consists in changing the weights of the customers of a p-median location problem at minimum cost such that a set of p prespecified suppliers becomes the p-median. The cost is proportional to the increase or decrease of the corresponding weight. We show that the discrete version of an inverse p-median problem can be formulated as a linear program. Therefore, it is polynomially solvable for fixed p even in the case of mixed positive and negative customer weights. In the case of trees with nonnegative vertex weights, the inverse 1-median problem is solvable in a greedy-like fashion. In the plane, the inverse 1-median problem can be solved in O(n log n) time, provided the distances are measured in L1- or l∝-norm, but this is not any more true in ℝ3 endowed with the Manhattan metric.