```python
def replace_list(list1, list2):
    """
    Replaces the last element of list1 with the elements of list2.
    """
    if not list1:
        list1.extend(list2)
        return

    list1[-1:] = list2
```