Entering a number in a repeating group and getting the total amount

Hello everyone I am writing through a translator, I hope the question will be clear.

In my application, after selecting several products, the user needs to be able to enter the weight of each product and get the total calorie content.

Step 1. The user has selected the right products
Step 2. We enter a value of 200 g and with the help of Custom States I was able to deduce the amount of avocado calories
Step 3. Problem. When I enter the volume of milk, the avocado data is replaced

How is it possible to get the total amount of calories without using a database? I do not want to use the database because the user can change the values many times to get the desired result. And there will be not only calories, but also proteins, fats and carbohydrates. I’m afraid it will be very expensive, because this is only 1/10 of the functionality of the application.

I will be very grateful for any advice!