Help me in solving DESTBRIDGE2 problem

My issue

can anyone explain me the third test-case here why the answer is 4 instead of 5.

My code

#include <bits/stdc++.h>
using namespace std; 

void solve() {
    long long n,c;
    cin>>n>>c;
    long long sum=0;
    vector<long long >arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    sort(arr.begin(),arr.end());
    long long ans=n;
    for(int i=0;i<n;i++){
        
        sum=sum-arr[i];
        long long b=sum*arr[i];
        c=c-b;
        if(c<0){break;}
        ans--;
    }
    if(ans==0){
        ans=1;
    }
    cout<<ans<<endl;
   

}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
  
    int t;
    cin >> t;
    while (t--) {
         solve();
    }


    return 0;
}

Problem Link: Destroying Bridges Part 2 Practice Coding Problem

Refer to the following code, we are aiming to simply divide the islands into two groups, 
So for test case :
6 1275 
5 10 10 15 25 35

we can optimally divide into two group (5, 10) and (10, 15, 25, 35)
within the group we don't need to destroy the bridge
so total cost = (5 + 10) * (10, 15, 25, 35) = 1275

Hope it is clear to you!

void solve(){
    ll n, c;
    cin >> n >> c;
    vll v(n);
    fr(i, 0, n){
        cin >> v[i];
    }
    ll sum = accumulate(all(v), 0ll);
    // if we can destroy the bridges from island 1 to all other islands, then we can only visit island 1
    if(v[0]*(sum-v[0]) <= c){
        cout << 1 << endl;
        return;
    }
    sort(all(v));
    ll curSum = 0;
    ll index = 0;
    fr(i, 0, n){
        curSum += v[i];
        ll toCutBridesBetweenCurGroupToRest = curSum*(sum - curSum);
        if(toCutBridesBetweenCurGroupToRest <= c){
            index = i + 1;
        }else{
            break;
        }

    }
    if(index == 0){
        cout << n << endl;
    }else{
        cout << n - index << endl;
    }
    return;
}