Use a temporary variable to store the value of the first element, then swap with the last element.