#include <iostream>
#include <list>
using namespace std;


int main() {
    int a;
    cin >> a;
    int data;
    list<int> lst;
    while (cin >> data) {
        lst.push_back(data);
    }

    auto it_first = lst.begin();
    auto it_second = std::next(it_first);

    auto it_last = lst.end();
    --it_last; // Move to the last element
    auto it_second_last = std::prev(it_last);

    // Swap the first two with the last two
    std::iter_swap(it_first, it_second);
    std::iter_swap(it_last, it_second_last);

    for (auto& i : lst)
        cout << i << " ";
}
// 64 位输出请用 printf("%lld")

没什么好说的,我是来偷懒的,大家别学我