Given a connected undirected graph of \(n\) vertices with \(m\) edges (may with negative weights)(edge \(i\) connects vertices \(u_i, v_i\) and with weight \(w_i\)), you can perform edge deletion, where the gain from deleting an edge is the edge weight of that edge, but you need to ensure that the graph remains connected after performing the edge deletion operation.
Your goal is to maximize the sum of the gains from all operations.