“Comrades, this man has a nice smile, but he’s got iron teeth.” -Andrei A. Gromyko
When you have a star, perhaps its most defining characteristic is that it fuses lighter elements into heavier ones, releasing energy. While all stars fuse hydrogen into helium, the more massive ones will undergo helium fusion, with the most massive also fusing carbon, oxygen, and eventually silicon, producing iron in the end. By time you get to iron, the most stable element of all, you would lose energy if you fused anything further, so iron’s the end-of-the-road, with a supernova as the next inevitable step.
Except, perhaps that picture is a bit oversimplified! Iron isn’t the only thing that gets produced in the silicon-burning phase, and once your star contains iron from previous generations of stars, there are a couple of different processes that can help you build elements very far up the periodic table, without needing to have a supernova or other cataclysmic event at all. When you talk about consuming versus producing energy, that’s a major factor, but arguably isn’t even the most important one when it comes to which elements you produce.