Let (X, \mathcal{A}) be a measurable space and let f : X \rightarrow [0, +\infty] be a measurable function. Find a set sequence \{A_n\}, A_n \in \mathcal{A}, such that f = \sum{n=1}^{\infty} \frac{1}{n} I_{A_n}, where I_A is a characteristic function.

I guess something's wrong with LaTeX, so I didn't use it.

At first I thought of a sequence A_n = \{ x \in X : f(x) = \frac{1}{n} \}, but it's wrong. Does anyone have any idea? It may be connected to a proof of Theorem 4.4.10 from "An introduction to the Theory of Real Functions" (author: Stanislaw Lojasiewicz), but I can't find out how.