You are given an integer array of length $n$.

You have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to $[x, x + 1, \dots, x + k - 1]$ for some value $x$ and length $k$.

Subsequence of an array can be obtained by erasing some (possibly zero) elements from the array. You can erase any elements, not necessarily going successively. The remaining elements preserve their order. For example, for the array $[5, 3, 1, 2, 4]$ the following arrays are subsequences: $[3]$, $[5, 3, 1, 2, 4]$, $[5, 1, 4]$, but the array $[1, 3]$ is not.


-----Input-----

The first line of the input containing integer number $n$ ($1 \le n \le 2 \cdot 10^5$) — the length of the array. The second line of the input containing $n$ integer numbers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) — the array itself.


-----Output-----

On the first line print $k$ — the maximum length of the subsequence of the given array that forms an increasing sequence of consecutive integers.

On the second line print the sequence of the indices of the any maximum length subsequence of the given array that forms an increasing sequence of consecutive integers.


-----Examples-----
Input
7
3 3 4 7 5 6 8

Output
4
2 3 5 6 

Input
6
1 3 5 2 4 6

Output
2
1 4 

Input
4
10 9 8 7

Output
1
1 

Input
9
6 7 8 3 4 5 9 10 11

Output
6
1 2 3 7 8 9 



-----Note-----

All valid answers for the first example (as sequences of indices):   $[1, 3, 5, 6]$  $[2, 3, 5, 6]$ 

All valid answers for the second example:   $[1, 4]$  $[2, 5]$  $[3, 6]$ 

All valid answers for the third example:   $[1]$  $[2]$  $[3]$  $[4]$ 

All valid answers for the fourth example:   $[1, 2, 3, 7, 8, 9]$

Difficulty: introductory

Starter code:

Solutions:
from collections import *
input()
a = list(map(int, input().split()))
m = defaultdict(int)
for x in reversed(a): m[x] = m[x + 1] + 1
v = max(list(m.keys()), key=m.get)
seq = []
for i, x in enumerate(a):
    if v == x:
        seq.append(i + 1)
        v += 1
print(len(seq))
print(*seq)


n= int(input());
a= list(map(int, input().split()));
#Словарь: пара число - максимальная длина последовательности, оканчивающаяся им.
d= dict();
for x in a:
    d[x]=d.get(x-1, 0)+1;
start=0;
finish=0;
result=0;
for key in d.keys():
    if d[key]>result:
        result=d[key];
        finish=key;
        start=key-d[key]+1;
print(result);
curr=start;
for i, x in enumerate(a):
    if curr==x:
        print(i+1, end=' ');
        curr+=1;
    


n=int(input())
a=list(map(int,input().split()))
h={}
for i in a:
    h[i-1]=0

tb=0
end=-1
for i in a:
    h[i]=h[i-1]+1
    if tb<h[i]:
        tb=h[i]
        end=i
arr=[]
start=end-tb+1
for i in range(n):
    if a[i]==start:
        arr.append(i+1)
        start+=1

print(tb)
print(*arr)


n = int(input())
s = list(map(int,input().split()))
rl = {}
best_range = range(0)
for x in s:
    run = rl[x] = rl.get(x-1, 0) + 1
    r = range(x-run+1, x+1)
    if len(r) > len(best_range):
        best_range = r
res = list(best_range)
size = len(res)
output = []
pointer = 0
for i,c in enumerate(s):
    if res[pointer] == c:
        output.append(str(i+1))
        pointer += 1
    
    if pointer >= size:break
print (size)
print (' '.join(output))

n = int(input())
a = input().split()
for i, x in enumerate(a):
    a[i] = int(x)

d = [float('inf')]*(n + 1)
d[0] = 0
length = 0
value = 0
s = dict()
for i in range(0, n):
    if a[i] - 1 in s:
        if a[i] is s:
            s[a[i]] = max(s[a[i]], s[a[i - 1]] + 1)
        else:
            s[a[i]] = s[a[i] - 1] + 1
    else:
        s[a[i]] = 1
    if s[a[i]] > length:
         length = s[a[i]]
         value = a[i]  
ans = []
value0 = value - length + 1
for i, x in enumerate(a):
    if x == value0:
        ans.append(i + 1)
        value0 = value0 + 1
        if value0 > value:
            break 
        
print(length)
print(' '.join(str(i) for i in ans))

    



from collections import defaultdict

n = int(input())
A = list(map(int, input().split()))
last = defaultdict(int)
D = {0: (0, 0)}
best = (0, 0)
for i, a in enumerate(A, start=1):
    last[a] = i
    last_a1 = last[a - 1]
    best_a1, _ = D[last_a1]
    D[i] = (1 + best_a1, last_a1)
    best = max(best, (1 + best_a1, i))

print(best[0])
rsseq = []
i = best[1]
while i != 0:
    rsseq.append(i)
    i = D[i][1]
print(' '.join(map(str, reversed(rsseq))))


n = int(input())
a = list(map(int, input().split()))
d = dict()
opt = []
m = -1
for i in range(n):
    t = a[i]
    p = t - 1
    if p in d:
        if (t not in d) or ((p - d[p]) >= (t - d[t])):
            d[t] = d[p]
            #d.pop(p)
            k = t - d[t]
            if k > m:
                m = k
                opt = d[t]
    else:
        if t not in d:
            d[t] = t
            if m == -1:
                opt = t
                m = 0
print(m+1)
r = []
for i in range(n):
    if a[i] == opt:
        r += [i+1]
        opt += 1
print(*r)

N = int(input())
D = {}
L = list(map(int,input().split()))[::-1]
for i in L:
	D[i] = max(D.get(i,0),D.get(i+1,0)+1)
M = max([(i[1],-i[0]) for i in D.items()])
L.reverse()
print(M[0])
M = -M[1]
for i in range(N):
	if L[i]==M:
		print(i+1,end=' ')
		M += 1

n = int(input())
a = [int(s) for s in input().split()]
lens = {}
maxlen = 1
maxlast = a[0]
for i in range(n):
    lens[a[i]] = lens.get(a[i]-1, 0) + 1
    if lens[a[i]] > maxlen:
        maxlen = lens[a[i]]
        maxlast = a[i]
# print(lens)
# print(maxlast, maxlen)
print(maxlen)
subs = []
si = maxlast - maxlen + 1
for i in range(n):
    if a[i] == si:
        subs.append(i+1)
        si += 1
print(*subs, sep=' ')

n=int(input())
d=dict()
m=0
val=0
a=list(map(int,input().split()))
s=set()
aps=s.add
for i in a:
    d[i]=d.get(i-1,0)+1
    if d[i]>m:
        m=d[i]
        val=int(i)

ans=[]
ap=ans.append
for i in range(n-1,-1,-1):
    if a[i]==val:
        val-=1
        ap(i+1)
print(m)
print(*ans[::-1])

n= int(input());
a= list(map(int, input().split()));
d= dict();
for x in a:
    d[x]=d.get(x-1, 0)+1;
start=0;
finish=0;
result=0;
for key in d.keys():
    if d[key]>result:
        result=d[key];
        finish=key;
        start=key-d[key]+1;
print(result);
curr=start;
for i, x in enumerate(a):
    if curr==x:
        print(i+1, end=' ');
        curr+=1;

n=int(input())
arr=list(map(int,input().split()))
arr.reverse()
d={}
for i in range(len(arr)):
    if arr[i]+1 in d.keys():
        d[arr[i]]=d[arr[i]+1]+1 
    else:
        d[arr[i]]=1 
maxx=0
number=0
for i in d.keys():
    if d[i]>maxx:
        maxx=d[i]
        number=i 
arr.reverse()
curr=number
print(maxx)
for i in range(n):
    if arr[i]==curr:
        print(i+1,end=" ")
        curr+=1


from collections import *
input()
a = list(map(int, input().split()))
m = defaultdict(int)
for x in reversed(a): m[x] = m[x + 1] + 1
v = max(m.keys(), key=m.get)
seq = []
for i, x in enumerate(a):
    if v == x:
        seq.append(i + 1)
        v += 1
print(len(seq))
print(*seq)

n = int(input())
a = list(map(int, input().split()))

d = {}

for ai in a:
  d[ai] = d.get(ai - 1, 0) + 1

maxRange = 0
endVal = 0
for key in d.keys():
  if (d[key] > maxRange):
    maxRange = d[key]
    endVal = key

startVal = endVal - maxRange + 1
print(maxRange)
for i, val in enumerate(a):
  if (val == startVal):
    print(i+1, end= ' ')
    startVal += 1


n = int(input())
arr = list(map(int, input().split()))
arr.reverse()
dic = {}

for i in range(n):
	dic[arr[i]] = dic[arr[i] + 1] + 1 if arr[i] + 1 in dic.keys() else 1
mx = 0
num = 0

for i in dic.keys():
	if dic[i] > mx:
		mx = dic[i]
		num = i 
print(mx)
arr.reverse()
for i in range(n):
	if arr[i] == num:
		print(i+1,end= ' ')
		num += 1

n=int(input())
a=list(map(int ,input().split() ) )
d={}
maxn=0
max_ind=0

for ai in a:
	d[ai]=d.get(ai-1,0)+1

for key in d.keys():
	if(d[key] >maxn):
	  maxn=d[key]
	  max_ind=key

start= max_ind-maxn+1
print(maxn)
i=0
for ai in a:
	i+=1
	if(ai==start):
                 print(i,end=' ')
                 start+=1
                 
	

n = int(input())
T = input().split(' ')
for i in range(n):
    T[i] = int(T[i])
D = {}
for i in range(n):
    D[T[i]] = 0
for i in range(n):
    if T[i]-1 not in D:
        D[T[i]] = 1
    else:
        D[T[i]] = D[T[i]-1] + 1
m = -1
j = -1
for i in D:
    if D[i] > m:
        m = D[i]
        j = i
L = []
for i in range(n-1, -1, -1):
    if T[i] == j:
        L.append(i)
        j -= 1
print(m)
for i in range(m-1):
    print(L[m-1-i]+1, end=' ')
print(L[0]+1)


n = int(input())
G = list(map(int,input().split()))
D = {}
M = 0
for i in G:
    if i-1 in D:
        D[i] = D[i-1] + 1
    else:
        D[i] = 1
    if D[i]>M:
        M = D[i]
        Mi = i
#print(M,Mi)
R = []
A = Mi
for i in range(len(G)-1,-1,-1):
    if G[i] == A:
        R.append(i+1)
        A-=1
print(M)
print(*R[::-1])

input()
a = list(map(int, input().split()))

b = {i: 0 for i in set(a)}

ans = 0
ans_ind = 0
for i in range(len(a)):
    if a[i] - 1 in b.keys():
        b[a[i]] = b[a[i] - 1] + 1
    else:
        b[a[i]] = 1
    if (b[a[i]] > ans):
        ans = b[a[i]]
        ans_ind = i
print(ans)
s = ""
aans = []
aans.append(ans_ind + 1)
x = a[ans_ind]
for i in range(ans - 1):
    while (a[ans_ind] != x - 1):
        ans_ind -= 1
    x = a[ans_ind]
    aans.append(ans_ind + 1)
for i in aans[::-1]:
    print(i, end=' ')

from collections import Counter


def read_nums():
    return [int(x) for x in input().split()]


def main():
    n, = read_nums()
    nums = read_nums()
    dp = Counter()
    for i in range(n):
        dp[nums[i]] = dp[nums[i] - 1] + 1

    indexes = {}
    for i in range(n):
        indexes[nums[i]] = i

    last_num = max(list(dp.items()), key=lambda x: x[1])[0]

    result = []
    for i in range(n - 1, -1, -1):
        if nums[i] == last_num:
            result.append(i)
            last_num -= 1

    result.reverse()
    print(len(result))
    print(' '.join([str(x + 1) for x in result]))


def __starting_point():
    main()

__starting_point()

n = int(input())
G = list(map(int,input().split()))
D = {}
M = 0
for i in G:
    if i-1 in D:
        D[i] = D[i-1] + 1
    else:
        D[i] = 1
    if D[i]>M:
        M = D[i]
        Mi = i
#print(M,Mi)
R = []
A = Mi
for i in range(len(G)-1,-1,-1):
    if G[i] == A:
        R.append(i+1)
        A-=1
print(M)
print(*R[::-1])

from collections import *
input()
a = list(map(int, input().split()))
m = defaultdict(int)
for x in reversed(a): m[x] = m[x + 1] + 1
v = max(list(m.keys()), key=m.get)
seq = []
for i, x in enumerate(a):
    if v == x:
        seq.append(i + 1)
        v += 1
print(len(seq))
print(*seq)


n = int(input())
a = [int(x) for x in input().split()]
b = [-1 for _ in range(n)]

dp = {}
best = -1
best2 = -1

for i, x in enumerate(a):
    p, q = dp.get(x, (1, i))
    r, t = dp.get(x - 1, (0, 0))

    if r + 1 > p:
        p, q = r + 1, i
    else:
        t = i

    dp[x] = (p, q)
    b[i] = t

    if best < 0 or dp[best][0] < p:
        best = x
        best2 = i

ans = []
m = dp[best][0]

for _ in range(m):
    ans.append(best2)
    best2 = b[best2]

ans.reverse()

print(len(ans))
print(' '.join([str(x + 1) for x in ans]))