from typing import List


def Partition(arr: List[int], front: int, rear: int):
    """

    Initially, taking the rear element as the pivot element

    :param arr:     An unsorted array of integers
    :param front:   the first element of the subarray
    :param rear:    the last element of the subarray
    :return:
    """
    pivot = arr[rear]

    i = front - 1
    for j in range(front, rear + 1):
        if arr[j] < pivot:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]

    arr[i + 1], arr[rear] = arr[rear], arr[i + 1]
    return i + 1