input: def min_final_element(n: int, x: int) -> int:
      """
      Given two integers n and x, construct an array of positive integers arr of length n such that for every 0 <= i < n - 1, arr[i + 1] is greater than arr[i]. The bitwise AND of all elements in arr should equal x.
  
      Return the smallest possible value of arr[n - 1].
  
      Examples:
      >>> n = 3, x = 4
      6
      >>> n = 2, x = 7
      15
  
      Constraints:
      1 <= n, x <= 10^8
      """
output:     
      # To solve this, we need to find a minimum arr[n-1] such that arr[0] & arr[1] & ... & arr[n-1] = x
      # We also need arr[i+1] > arr[i] for all 0 <= i < n - 1
      # Starting with the smallest possible value for the bitwise AND
      if n == 1:
          return x
  
      # We need n-1 elements which are smaller than the final element, and all of them should respect the AND condition
      # The strategy is to fill the first n-1 elements with values that are just large enough, then satisfy the AND condition at the end
      # This could be done with simply: n-1 elements being `x` and finally making sure the last one is larger
  
      if x == 0:
          # If x is 0, arr[n-1] must be at least n-1, as all zeros are allowed before it to not affect AND
          return (n - 1)
  
      # Start with the smallest array of form: [x, x, x, ..., final]
      smallest_final_element = x
  
      # Keep incrementing the final element until the array satisfies the conditions
      while True:
          candidate = smallest_final_element + n - 1
          # Simulating the array: [x, x, ..., candidate] 
          if candidate & x == x:
              return candidate
          smallest_final_element += 1
  