Energy flows into an ecosystem as sunlight and ultimately leaves as heat, while the chemical elements essential to life are recycled.