#include <iostream>
#include <vector>
#include <sstream>
#include <string>
int main()
{
int numberAmount;
std::cin >> numberAmount;
std::cin.ignore(1, '\n');
std::string sNumbers;
std::getline(std::cin, sNumbers);
std::istringstream is(sNumbers);
int x;
std::vector<int> numbers;
while (is >> x)
{
numbers.push_back(x);
}
std::vector<int> rotates;
unsigned int n = numbers.size();
for (unsigned int i = n; i > 0; i--)
{
for (unsigned int j = 0; j < i; j++)
{
if (numbers[j] == i && (j + 1) != i)
{
if (j > 0)
{
std::reverse(numbers.begin(), numbers.end() - (n - j - 1));
rotates.push_back(j + 1);
}
std::reverse(numbers.begin(), numbers.end() - (n - i));
rotates.push_back(i);
}
}
}
std::cout << rotates.size() << '\n';
for (unsigned int x = 0; x < rotates.size(); x++)
{
std::cout << rotates[x] << " ";
}
return 0;
}