This paper considers two-hop communication networks where the transmitters harvest their energy in an intermittent fashion. In this network, communication is carried out by signal cooperation, i.e., relaying. Additionally, the transmitters have the option of transferring energy to one another, i.e., energy cooperation. Energy is partially lost during transfer, exposing a trade-off between energy cooperation and use of harvested energy for transmission. A multi-access relay model is considered and transmit power allocation and energy transfer policies that jointly maximize the sum-rate are found. It is shown that a class of power policies achieves the optimal sum-rate, allowing a separation of optimal energy transfer and optimal power allocation problems. The optimal energy transfer policy is shown to be an ordered node selection, where nodes with better energy transfer efficiency and worse channels transfer all their energy to the relay or other source nodes via the relay. For the special case of single source, the optimal policy requires the direction of energy transfer to remain unchanged unless either node depletes all of its energy. Overall, the findings provide the insight that cooperation of the source nodes by sharing energy with the relay node leads to them indirectly cooperating with each other, and that such cooperation can be carried out in a last-minute fashion.