How can I get the updated sum of a list of floats?

So it´s basically getting a total sum that updates every time the groundBases´size changes

 for (int i = 0; i < groundBases.Count; i++)
 {
       allGroundBases += groundBases*.GetComponent<MeshFilter>().mesh.bounds.size.x;*

//groundBases[] are gameObjects, but am adding only the size.x float values
}
I thought that this would be enough, but it seems that it updates too much and never stops increasing. I know that is because it keeps its actual size and then adds again at every frame, but I don´t know how to reset it after it changes (or whatever I have to do) and stop it when all the groundBase sizes have been added.
Thanks in advance.

Something like this?

using System.Linq;

public float GetSumBounds(GameObject[] groundBases) 
{
     return groundBases.Sum(f => f.GetComponent<MeshFilter>().mesh.bounds.size.x);
}

You call this method everytime u want to know the updated sum,

also you might want to find a way to cache the meshfilters if you’re gonna call this a lot.

float groundBasesTemp = 0.0f;
for (int i = 0; i < groundBases.Count; i++)
{
    groundBasesTemp += groundBases*.GetComponent<MeshFilter>().mesh.bounds.size.x;* 
 *//groundBases[] are gameObjects, but am adding only the size.x float values*
*}*
*allGroundBases = groundBasesTemp;*
*```*