The One with All the Candy Practice Problem in 1800 to 2000 difficulty problems

this problem had one test case , and according to me ans should be 87 not 95

can someone explain how 95 will be ans , it will help me identify where I am lacking

Given Test Case

1
97
0 2 4 2 7 6 8 5 11 0 20 9 19 22 6 23 14 24 20 37 10 7 20 5 30 27 36 37 34 26 32 22 21 51 39 32 53 28 46 59 30 25 58 25 62 75 68 35 42 20 55 33 36 18 89 77 84 70 56 63 43 74 41 70 78 99 90 75 110 75 94 105 55 99 48 72 86 99 110 123 26 130 55 111 125 15 128 51 79 105 149 86 133 67 157 77 29

fn solution(n: u32, arr: &Vec<u32>) -> i32 {
    let mut nums = arr.clone();
    let min_ele = *arr.iter().min().unwrap();

    let mut i = 0;
    while i < arr.len() {
        if min_ele == arr[i] {
            for j in 0..i {
                nums.push(arr[j]);
            }
            break;
        }
        i += 1;
    }

    let mut ans: i32 = 0;
    let mut i = 0;
    let mut sum = 0;
    
// println!("{:?}", nums);

    while i < nums.len() {
        if nums[i] == 0 {
            sum = 0;
        } else {
            sum += 1;
        }

        if ans < sum {
            ans = sum;
        }
        i += 1;
    }

    let mut i = arr.len();
    while i > 0 {
        i -= 1;

        if min_ele == arr[i] {
            let tmp = (arr.len() - i) as i32
                + (min_ele * arr.len() as u32) as i32 - 1;

            if ans < tmp {
                ans = tmp;
            }
            break;
        }
    }

    ans
}```