1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
n=int(input())
h=[]
for i in range(n):
    h.append([int(input()),i])
h.sort()
ss=[]
for i in range(n):
    ss.append(h[i][1])
s=[0 for i in range(n)]
for i in range(n):
    s[ss[i]]=i
#print(*s)
#print(*ss)
u=True
k=0
d=[]
while u:
    t=[False for i in range(n)]
    a=[]
    b=[]
    u=False
    w=True
    for j in range(n):
        if s[j]==j:
            continue
        if t[j]:
            continue
        w=False
        h=[]
        u=True
        while not t[j]:
            t[j]=True
            h.append(j)
            j=s[j]
            
            
            
        for i in range(len(h)//2):
            
            a.append(h[i]+1)
            b.append(h[-i-1]+1)
    if w:
        continue
    d.append(a+b[::-1])
    for i in range(len(a)):
        g=s[a[i]-1]
        s[a[i]-1]=s[b[i]-1]
        s[b[i]-1]=g
    k+=1
    #print(*s)
print(k)
for z in d:
    print(len(z))
    print(*z)