We study the local behavior of plurisubharmonic functions at singular points by defining the notion of order function for a plurisubharmoic function. This leads us to introduce a new classes of real valued functions, so called G_delta-functions. These functions are characterized as limits of decreasing sequences of lower semicontinuous functions. The order functions are special G_delta-functions which are constant outside a pluripolar set. The constant is the Lelong number. We offer a tecnique to construct plurisubharmonic functions with prescribed order function and prove that for every G_delta-function f equal to a constant outside a countable set there is a maximal plurisubharmonic function whose order function coincides with f. This shows that the space of fundamental solutions to the homogeneous Monge-Ampere equation has very complicated structure. We apply this theory to get the result that the set of all functions that are plurisubharmonic on the unit ball, maximal on the punctured unit ball, with zero boundary values and singularity at zero is infinite dimensional over the set of positive real numbers. This result has no analogue in the complex plane.