Kamala had 5026 g. Of flour in a bag. She bought another packet of flour of mass 4157 g. She transferred some flour from the packet to the bag. Then the mass of the flour in the bag became twice the mass of the flour left in the packet. How much flour was in the packet in the end?