Just a runnable solution
\n\nimpl Solution {\n    pub fn earliest_second_to_mark_indices(nums: Vec<i32>, change_indices: Vec<i32>) -> i32 {\n        let mut change_indices = change_indi
\n```\nimpl Solution {\n    pub fn earliest_second_to_mark_indices(nums: Vec<i32>, change_indices: Vec<i32>) -> i32 {\n        let mut change_indices = change_indices;\n        let m = change_indices.len() as i64;\n        let _n = nums.len() as i64;\n        let mut l: i64;\n        let mut mid: i64;\n\n        for x in change_indices.iter_mut() {\n            *x -= 1;\n        }\n\n        l = nums.iter().fold(0_i64, |sum, x| sum + (*x as i64));\n        let mut r = m + 1;\n\n        if l > m {\n            return -1;\n        }\n\n        while l < r {\n            mid = l + (r - l) / 2;\n\n            if Self::enable_to_mark_indices(&nums, &change_indices, mid as i32) {\n                r = mid;\n            } else {\n                l = mid + 1;\n            }\n        }\n\n        if l <= m {\n            l as i32\n        } else {\n            -1\n        }\n    }\n\n    fn enable_to_mark_indices(nums: &[i32], change_indices: &[i32], m: i32) -> bool {\n        let n = nums.len();\n        let mut last_indices: Vec<(i32, usize)> = Vec::with_capacity(n);\n        for i in 0..n {\n            last_indices.push((-1, i));\n        }\n\n        for i in 0..m {\n            last_indices[change_indices[i as usize] as usize].0 = i;\n        }\n\n        let mut sum = 0;\n        last_indices.sort();\n        for (i, (last, x)) in last_indices.into_iter().enumerate() {\n            sum += nums[x];\n            if last < i as i32 + sum {\n                return false;\n            }\n        }\n\n        true\n    }\n}\n\n```
['Rust']