Algae and cyanobacteria are capable of photosynthesis: capturing energy from sunlight and storing that energy in carbohydrates (sugars).

After they died, their energy-rich remains were buried under layers of sediment.

Some of these deposits were not completely decomposed, and under heat and pressure they eventually turned into fossil fuels such as crude oil and natural gas.

Thus the petroleum and oil shale being harvested today on the Great Plains are "fossil sunbeams" that may be 450 million years old.