#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <cmath>
using namespace std;
void
reverse (int *list, int length, int num)
{
int swap;
int i=0;
for(i;i<--num;i++)
{
swap=list[i];
list[i]=list[num];
list[num]=swap;
}
}
int
atoi (string c)
{
stringstream s;
int i;
s << c;
s >> i;
return i;
}
vector<int>
into_vec (string str, int size)
{
vector<int> vec(size);
istringstream ssin(str);
int input, j = 0;
while(ssin >> input) {
vec[j] = input;
j++;
}
return vec;
}
int
main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
string in;
int c;
getline (cin, in);
c = atoi (in);
int vec[c];
int job[2*c] = {0};
getline (cin, in);
istringstream ssin(in);
int inp, i, j;
i = 0;
while (ssin >> inp) {
vec[inp-1] = i;
i++;
}
cout << 2*c << "\n";
int n = 0;
for (i = c; i > 0; i--) {
if (vec[i-1] == i) {
cout << "1 1 ";
} else {
int plc = vec[i-1];
int j;
for (j = 0; j < n; j++)
plc = (int)abs((double)(plc-job[j]));
cout << plc+1 << " " << i << " ";
job[n] = plc+1;
n++;
job[n] = i;
n++;
}
}
cout << "\n";
return 0;
}