
function s = sums (f, R, parent)
    [_, i] = sort(f(:), "descend");
    
    s = zeros(size(f));
    
    for x = i'
        s(x) = f(x) ^ 2;
    end
    
    for x = i'
        if x != parent(x)
            s(parent(x)) = s(parent(x)) + s(x);
        end
    end
end
