Suppose $(X,\mathcal{O}_X)$ and $(Y,\mathcal{O}_Y)$ are locally ringed spaces. Then morphisms glue, that is, if $\{U_i\}_i$ is an open cover of $X$, then "to give a morphism $X\to Y$ is the same as giving morphisms $U_i\to Y$ that agree on overlaps".
This sentence is formally similar to the sentence that expresses the condition a presheaf needs to satisfy in order to be a sheaf. So one can try to say that the above sentence can be expressed as: there is an exact sequence
$0\to Mor(X,Y)\to \prod_i Mor(U_i, Y)\to \prod_{i,j} Mor(U_i\cap U_j,Y)$
and I have just seen this in a couple of solutions I found online to an exercise in Hungerford.
However I can't make sense of this. The first map would be $f\mapsto (f|_{U_i})$, but what would be the second map? The expression $(f_i)\mapsto ((f_i-f_j)|_{U_i\cap U_j})$ doesn't make sense, does it? What does it mean to substract morphisms of ringed spaces? And more importantly, what does exactness of the final arrow mean?
Am I missing something obvious? Is there any way around this?