  First, we obtain a new formula for Bremermann type upper envelopes, that
arise frequently in convex analysis and pluripotential theory, in terms of the
Legendre transform of the convex- or plurisubharmonic-envelope of the boundary
data. This yields a new relation between solutions of the Dirichlet problem for
the homogeneous real and complex Monge-Ampere equations and Kiselman's minimum
principle. More generally, it establishes partial regularity for a Bremermann
envelope whether or not it solves the Monge-Ampere equation. Second, we prove
the second order regularity of the solution of the free-boundary problem for
the Laplace equation with a rooftop obstacle, based on a new a priori estimate
on the size of balls that lie above the non-contact set. As an application, we
prove that convex- and plurisubharmonic-envelopes of rooftop obstacles have
bounded second derivatives.
