Let $\{U_\lambda\}_{\lambda\in\Lambda}$ be an open covering of $\mathbb{R}^n$.
Given a family of functions $f_\lambda:U_\lambda\rightarrow \mathbb{R}\,(\lambda\in\Lambda)$ such that $f_\lambda-f_\mu: U_\lambda\cap U_\mu\rightarrow\mathbb{R}$ is constant for any $\lambda,\mu\in\Lambda$, is there a function $f:\mathbb{R}^n\rightarrow \mathbb{R}$ such that for each $\lambda\in\Lambda$, the function $f-f_\lambda$ is constant on $U_\lambda$?

It seems like that this assertion is true, but I don't have any proof.