#include <iostream>
static long N = 1<<17;
using namespace std;
int sp[N<<1];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int t[n];
int mloc[n+1];
for (int i = 0; i < n; ++i) cin >> t[i], mloc[t[i]] = i;
cout << 4*n << endl;
for (int i = 0; i < n; ++i) {
int cur_i = mloc[n-i];
int a = N, b = N+cur_i;
while (a <= b) {
if (a%2) cur_i -= sp[a++];
if (!(b%2)) cur_i -= sp[b--];
a >>= 1; b >>= 1;
}
int j = N+mloc[n-i];
for (; j >= 1; j >>= 1) {
sp[j]++;
}
cout << cur_i+1 << ' ' << n-i << ' ' << max(n-i-1, 1) << ' ' << max(cur_i, 1) << ' ';
}
}