#include <iostream>
void swap(int * buf, int swapcount) {
int * swapped = new int[swapcount];
for (int i = 0; i < swapcount; i++) {
swapped[i] = buf[swapcount - 1 - i];
}
memcpy(buf, swapped, swapcount * 4);
}
int search(int * buf, int buflen, int searchfor) {
for (int i = 0; i < buflen; i++) {
if (buf[i] == searchfor) {
return i;
}
}
return -1;
}
int main() {
int tableSize;
std::cin >> tableSize;
std::cin.get();
int * table = new int[tableSize];
for (int i = 0; i < tableSize; i++) {
std::cin >> table[i];
}
std::cin.get();
//do the thing
int * swaps = new int[500000];
int swapcount = 0;
for (int i = 0; i < tableSize; i++) {
int found = search(table, tableSize, tableSize-i);
if (found != tableSize - 1 - i) {
swap(table, found + 1);
swap(table, tableSize - i);
//record the swaps
swaps[swapcount] = found + 1;
swaps[swapcount + 1] = tableSize - i;
swapcount = swapcount + 2;
}
}
std::cout << swapcount << "\n";
for (int i = 0; i < swapcount; i++) {
std::cout << swaps[i] << " ";
}
std::cout << "\n";
std::cin.get();
return 0;
}