  This paper and its sequel prove a generalization of the usual gluing theorem
for two index 1 pseudoholomorphic curves u_+ and u_- in the symplectization of
a contact 3-manifold. We assume that for each embedded Reeb orbit gamma, the
total multiplicity of the negative ends of u_+ at covers of gamma agrees with
the total multiplicity of the positive ends of u_- at covers of gamma. However,
unlike in the usual gluing story, here the individual multiplicities are
allowed to differ. In this situation, one can often glue u_+ and u_- to an
index 2 curve by inserting genus zero branched covers of R-invariant cylinders
between them. We establish a combinatorial formula for the signed count of such
gluings. As an application, we deduce that the differential d in embedded
contact homology satisfies d^2=0. This paper explains the more algebraic
aspects of the story, and proves the above formulas using some analytical
results from part II.
