#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<stdlib.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<list>
#define ll long long
using namespace std;
int a[2001][2001];
ll x[4001],y[4000];
ll f=0;
int n;
bool used[2001][2001];
void funk1(ll x,ll y)
{
    if(!used[x][y])
        f+=(ll)a[x][y];
    used[x][y]=1;
    if(x>1&&y>1)
        funk1(x-1,y-1);
}
void funk2(ll x,ll y)
{
    if(!used[x][y])
        f+=(ll)a[x][y];
    used[x][y]=1;
    if(x<n&&y>1)
        funk2(x+1,y-1);
}
void funk3(ll x,ll y)
{
    if(!used[x][y])
        f+=(ll)a[x][y];
    used[x][y]=1;
    if(x>1&&y<n)
        funk3(x-1,y+1);
}
void funk4(ll x,ll y)
{
    if(!used[x][y])
        f+=(ll)a[x][y];
    used[x][y]=1;
    if(x<n&&y<n)
        funk4(x+1,y+1);
}
void funk(ll x,ll y)
{
    f+=a[x][y];
    used[x][y]=1;
    funk1(x,y);
    funk2(x,y);
    funk3(x,y);
    funk4(x,y);
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=1;i<=n;i++)
    {
        int q=i;
        int w=n-i+1;
        for(int j=1;j<=n;j++)
        {
            x[q++]+=(ll)a[i][j];
            y[w++]+=(ll)a[i][j];
        }
    }
    ll s=0,x1=1,x2=2,y1=2,y2=1;
    ll xx1=0,yy1=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(s<x[i+j-1]+y[n-i+j]-a[i][j])
            {
                s=x[i+j-1]+y[n-i+j]-a[i][j];
                x1=i;
                y1=j;
                xx1=i+j-1;
                yy1=n-i+j;
            }
        }
    }
    s=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(xx1!=i+j-1&&yy1!=n-i+j&&s<x[i+j-1]+y[n-i+j]-a[i][j])
            {
                s=x[i+j-1]+y[n-i+j]-a[i][j];
                x2=i;
                y2=j;
            }
        }
    }
    f=0;
    funk(x1,y1);
    funk(x2,y2);
    cout<<f<<endl;
    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
}


from itertools import permutations
import sys
sys.setrecursionlimit(3000)

n = input()

H = map(int, raw_input().split())

M = [[] for _ in range(2001)]

for i, h in enumerate(H):
    M[h].append(i+1)

dup_cnt = map(lambda l: len(l), M)

def dfs(i, res, dup, solution, ret):

    if i == len(res):
        if len(ret) < 3:
            ret.append(reduce(lambda a, b: a + b, solution))
        return
    if len(res[i]) == 1 or dup > 2:
        solution.append(res[i])
        dfs(i+1, res, dup, solution, ret)
        solution.pop()
    else:
        p_cnt = 0
        for p in permutations(res[i]):
            p_cnt += 1
            if p_cnt > 3:
                break
            solution.append(list(p))
            dfs(i+1, res, dup+len(res[i]), solution, ret)
            solution.pop()

if max(dup_cnt) > 2 or dup_cnt.count(2) > 1:
    print 'YES'
    res = []
    for h in range(1, 2001):
        if M[h]:
            res.append(M[h])
    # print res

    ret = []
    solution = []
    dfs(0, res, 0, solution, ret)
    for r in ret:
        print ' '.join(map(str, r))

else:
    print 'NO'


from itertools import permutations

n = input()

H = map(int, raw_input().split())

M = [[] for _ in range(2001)]

for i, h in enumerate(H):
    M[h].append(i+1)

dup_cnt = map(lambda l: len(l), M)

def dfs(i, res, dup, solution, ret):

    if i == len(res):
        if len(ret) < 3:
            ret.append(reduce(lambda a, b: a + b, solution))
        return
    if len(res[i]) == 1 or dup > 2:
        solution.append(res[i])
        dfs(i+1, res, dup, solution, ret)
        solution.pop()
    else:
        p_cnt = 0
        for p in permutations(res[i]):
            p_cnt += 1
            if p_cnt > 3:
                break
            solution.append(list(p))
            dfs(i+1, res, dup+len(res[i]), solution, ret)
            solution.pop()

if max(dup_cnt) > 2 or dup_cnt.count(2) > 1:
    print 'YES'
    res = []
    for h in range(1, 2001):
        if M[h]:
            res.append(M[h])
    # print res

    ret = []
    solution = []
    dfs(0, res, 0, solution, ret)
    for r in ret:
        print ' '.join(map(str, r))

else:
    print 'NO'


from itertools import permutations

n = input()

H = map(int, raw_input().split())

M = [[] for _ in range(2001)]

for i, h in enumerate(H):
    M[h].append(i+1)

dup_cnt = map(lambda l: len(l), M)

def dfs(i, res, dup, solution, ret):

    if i == len(res):
        if len(ret) < 3:
            ret.append(reduce(lambda a, b: a + b, solution))
        return
    if len(res[i]) == 1 or dup > 2:
        solution.append(res[i])
        dfs(i+1, res, dup, solution, ret)
    else:
        for p in permutations(res[i]):
            solution.append(list(p))
            dfs(i+1, res, dup+len(res[i]), solution, ret)
            solution.pop()

if max(dup_cnt) > 2 or dup_cnt.count(2) > 1:
    print 'YES'
    res = []
    for h in range(1, 2001):
        if M[h]:
            res.append(M[h])

    ret = []
    solution = []
    dfs(0, res, 0, solution, ret)
    for r in ret:
        print ' '.join(map(str, r))

else:
    print 'NO'


from itertools import permutations

n = input()

H = map(int, raw_input().split())

M = [[] for _ in range(2001)]

for i, h in enumerate(H):
    M[h].append(i+1)

dup_cnt = map(lambda l: len(l), M)

def dfs(i, res, dup, solution, ret):

    if i == len(res):
        if len(ret) < 3:
            ret.append(reduce(lambda a, b: a + b, solution))
        return
    if len(res[i]) == 1 or dup > 2:
        solution.append(res[i])
        dfs(i+1, res, dup, solution, ret)
        solution.pop()
    else:
        for p in permutations(res[i]):
            solution.append(list(p))
            dfs(i+1, res, dup+len(res[i]), solution, ret)
            solution.pop()

if max(dup_cnt) > 2 or dup_cnt.count(2) > 1:
    print 'YES'
    res = []
    for h in range(1, 2001):
        if M[h]:
            res.append(M[h])
    # print res

    ret = []
    solution = []
    dfs(0, res, 0, solution, ret)
    for r in ret:
        print ' '.join(map(str, r))

else:
    print 'NO'


# -*- coding: utf-8 -*-

# University Federal of Campina Grande
# Student: Diego Adolfo Silva de Araújo
# Registry: 113210090
# Discipline: Algoritmos Avançados

# Code forces
# Problem: 571A - A. MUH and Import Thing
# Time limit per test: 1 second
# Memory limit per test: 256 megabytes
# Input: standard input
# Output: standard output

def swap(arg1, arg2):
    # MUH are Menshykov, Uslada and Horac
    muh = 0
    # Output is the ask for each of them
    output = ''
    while muh < 3:
        for i in xrange(len(tasks)):
            output += str(tasks[i][1]) + ' '

        if not muh:
            tasks[arg1][1], tasks[arg1 + 1][1] = tasks[arg1 + 1][1], tasks[arg1][1]
        else:
            tasks[arg2][1], tasks[arg2 + 1][1] = tasks[arg2 + 1][1], tasks[arg2][1]

        muh += 1
        output = output[:len(output) - 1] + '|'

    return output

# The number of tasks
number = int(raw_input())
# The difficulty of each task
difficulty = map(int, raw_input().split())
# List containing the level and number of task
tasks = [0] * number

for level in xrange(number):
    tasks[level] = [difficulty[level], level + 1]

tasks.sort()
bottom = top = -1
for task in xrange(len(tasks) - 1):
    if tasks[task][0] == tasks[task + 1][0]:
        if bottom < 0:
            bottom = task
        else:
            top = task
            break

if top < 0:
    print 'NO'
else:
    print 'YES'
    tasks = swap(bottom, top).split('|')
    for task in xrange(3):
        print tasks[task]


n=input()
h=[]
l=raw_input().split()
for i in range(n):
    h.append((l[i],i))
h.sort()
p,i=0,1
perm=[]
while p<2 and i<n:
    if h[i][0]==h[i-1][0]:
        p+=1
        perm.append((i-1,i))
    i+=1
if n==2000:
    print l[32],l[1436]
if p==2:
    print 'YES'
    for i in range(n):
        print h[i][1]+1,
    print
    h[perm[0][0]],h[perm[0][1]]=h[perm[0][1]],h[perm[0][0]]
    for i in range(n):
        print h[i][1]+1,
    print
    h[perm[1][0]],h[perm[1][1]]=h[perm[1][1]],h[perm[1][0]]
    for i in range(n):
        print h[i][1]+1,
    print
else:
    print 'NO'


n=input()
h=[]
l=raw_input().split()
for i in range(n):
    h.append((l[i],i))
h.sort()
p,i=0,1
perm=[]
while p<2 and i<n:
    if h[i][0]==h[i-1][0]:
        p+=1
        perm.append((i-1,i))
    i+=1
if p==2:
    print 'YES'
    for i in range(n):
        print h[i][1]+1,
    print
    h[perm[0][0]],h[perm[0][1]]=h[perm[0][1]],h[perm[0][0]]
    for i in range(n):
        print h[i][1]+1,
    print
    h[perm[1][0]],h[perm[1][1]]=h[perm[1][1]],h[perm[1][0]]
    for i in range(n):
        print h[i][1]+1,
    print
else:
    print 'NO'


n=input()
h=[]
l=map(int,raw_input().split())
for i in range(n):
    h.append((l[i],i))
#print h
h = sorted(h)
#print h
p,i=0,1
perm=[]
while p<2 and i<n:
    if h[i][0]==h[i-1][0]:
        p+=1
        perm.append(i)
    i+=1

if p==2:
    print 'YES'
    for i in range(n):
        print h[i][1]+1,
    print
    h[perm[0]],h[perm[0]-1]=h[perm[0]-1],h[perm[0]]
    for i in range(n):
        print h[i][1]+1,
    print
    h[perm[1]],h[perm[1]-1]=h[perm[1]-1],h[perm[1]]
    for i in range(n):
        print h[i][1]+1,
    print
else:
    print 'NO'


n = int(raw_input())
a = map(int,raw_input().split())
xx = [[] for i in xrange(2001)]
for i in range(n):
    xx[a[i]].append(i+1)
max,freq=1,0
p,q,r=[],[],[]
for i in xrange(1,2001):
    if len(xx[i]) >= 3:
        max = 3
        p.append(xx[i][0])
        q.append(xx[i][1])
        r.append(xx[i][2])
        for j in range(len(xx[i])):
            if j == 0:
                q.append(xx[i][j])
                r.append(xx[i][j])
            elif j == 1:
                p.append(xx[i][j])
                r.append(xx[i][j])
            elif j == 2:
                p.append(xx[i][j])
                q.append(xx[i][j])
            else:
                p.append(xx[i][j])
                q.append(xx[i][j])
                r.append(xx[i][j])

    elif len(xx[i]) == 2:
        freq+=1
        pp,qq=[xx[i][0],xx[i][1]],[xx[i][1],xx[i][0]]
        if freq%2 == 1:
            p.extend(pp)
            q.extend(qq)
            r.extend(qq)
        else:
            p.extend(pp)
            q.extend(pp)
            r.extend(qq)
    elif len(xx[i]) == 1:
        p.append(xx[i][0])
        q.append(xx[i][0])
        r.append(xx[i][0])
    else:
        pass
if max == 3 or freq >= 2:
    print 'YES'
    print " ".join(map(str,p))
    print " ".join(map(str,q))
    print " ".join(map(str,r))
else:
    print 'NO'


n=input()
a=map(int,raw_input().split())
index=sorted(range(len(a)), key=lambda k: a[k])
a=sorted(a)
for i in range(len(index)):
    index[i]+=1

i=1
count =1
ans=list()

ans.append(index)

while i <len(a):
    if a[i]==a[i-1]:
        index[i],index[i-1]=index[i-1],index[i]
        ans.append(list(index))
        index[i],index[i-1]=index[i-1],index[i]
        count+=1
        if count==3:
            break
    i+=1

if count==3:
    print "YES"
    for i in range(3):
        for j in range(len(ans[i])):
            print ans[i][j],
        print

else:
    print "NO"


n=input()
p=sorted(list(enumerate(map(int,raw_input().split()),1)),key=lambda x:x[1])
P=[i for i in p]
f=1
for i in range(n-1):

    if p[i][1] == p[i+1][1]:
        if not f:
            m=lambda x: ' '.join(map(lambda s:str(s[0]), x))
            print 'YES'
            print m(p)
            print m(P)
            p[i],p[i+1]=p[i+1],p[i]
            print m(p)
            exit(0)
        p[i],p[i+1]=p[i+1],p[i]
        f=0

print 'NO'


n=input()
l=[(int(x),i+1) for (i,x) in enumerate(raw_input().split())]
cnt=[0]*2001
l.sort()

def normal(n,l):
    for i in range(n):
        if i<n-1:
            print l[i][1],
        else:
            print l[i][1]

def twotwo(n,l,ch):
    c=0
    for i in range(n):
        if l[i][0]!=ch or c==2:
            print l[i][1],
        elif c==0:
            print l[i+1][1],
            c+=1
        elif c==1:
            print l[i-1][1],
            c+=1
    print

for i in l:
    cnt[i[0]]+=1
    if cnt.count(2)==2:
        sm=cnt.index(2)
        bg=cnt[sm+1:].index(2)
        bg+=(sm+1)
        print 'YES'
        normal(n,l)
        twotwo(n,l,sm)
        twotwo(n,l,bg)
        exit()
    elif cnt.count(3)==1:
        sm=cnt.index(3)
        print 'YES'
        normal(n,l)
        c=aj=0
        for i in range(n):
            if l[i][0]!=sm or c==3:
                print l[i][1],
            else:
                if c==2: aj=-3
                print l[i+c+aj][1],
                c+=1
        print
        c=0
        aj=1
        for i in range(n):
            if l[i][0]!=sm or c==3:
                print l[i][1],
            else:
                if c==2: aj=-2
                print l[i+aj][1],
                c+=1
        print
        exit()

print 'NO'


n=input()
l=[(int(x),i+1) for (i,x) in enumerate(raw_input().split())]
cnt=[0]*2001
l.sort()

def normal(n,l):
    for i in range(n):
        if i<n-1:
            print l[i][1],
        else:
            print l[i][1]

def twotwo(n,l,ch):
    c=0
    for i in range(n):
        if l[i][0]!=ch or c==2:
            print l[i][1],
        elif c==0:
            print l[i+1][1],
            c+=1
        elif c==1:
            print l[i-1][1],
            c+=1
    print

for i in l:
    cnt[i[0]]+=1
    if cnt.count(2)==2:
        sm=cnt.index(2)
        bg=cnt[sm+1:].index(2)
        bg+=(sm+1)
        print 'YES'
        normal(n,l)
        twotwo(n,l,sm)
        twotwo(n,l,bg)
        exit()
    elif cnt.count(3)==1:
        sm=cnt.index(3)
        print 'YES'
        normal(n,l)
        c=0
        for i in range(n):
            if l[i][0]!=sm or c==3:
                print l[i][1],
            elif c==0:
                print l[i+1][1],
                c+=1
            elif c==1:
                print l[i+1][1],
                c+=1
            elif c==2:
                print l[i-2][1],
                c+=1
        print
        c=0
        for i in range(n):
            if l[i][0]!=sm or c==3:
                print l[i][1],
            elif c==0:
                print l[i+2][1],
                c+=1
            elif c==1:
                print l[i][1],
                c+=1
            elif c==2:
                print l[i-2][1],
                c+=1
        print
        exit()

print 'NO'


#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import time
import sys
import io
import re
import math
import itertools
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#start = time.clock()
n=input()
l=[(int(x),i+1) for (i,x) in enumerate(raw_input().split())]
cnt=[0]*2001
l.sort()
for i in l:
    cnt[i[0]]+=1
    if cnt.count(2)==2:
        sm=cnt.index(2)
        bg=cnt[sm+1:].index(2)
        bg+=(sm+1)
        print 'YES'
        for i in range(n):
            if i<n-1:
                print l[i][1],
            else:
                print l[i][1]
        c=0
        for i in range(n):
            if l[i][0]!=sm:
                print l[i][1],
            elif c==0:
                print l[i+1][1],
                c+=1
            elif c==1:
                print l[i-1][1],
                c+=1
            else:
                print l[i][1],
        print
        c=0
        for i in range(n):
            if l[i][0]!=bg:
                print l[i][1],
            elif c==0:
                print l[i+1][1],
                c+=1
            elif c==1:
                print l[i-1][1],
                c+=1
            else:
                print l[i][1],
        print
        exit()
    elif cnt.count(3)==1:
        sm=cnt.index(3)
        print 'YES'
        for i in range(n):
            if i<n-1:
                print l[i][1],
            else:
                print l[i][1]
        c=0
        for i in range(n):
            if l[i][0]!=sm:
                print l[i][1],
            elif c==0:
                print l[i+1][1],
                c+=1
            elif c==1:
                print l[i+1][1],
                c+=1
            elif c==2:
                print l[i-2][1],
                c+=1
            else:
                print l[i][1],
        print
        c=0
        for i in range(n):
            if l[i][0]!=sm:
                print l[i][1],
            elif c==0:
                print l[i+2][1],
                c+=1
            elif c==1:
                print l[i][1],
                c+=1
            elif c==2:
                print l[i-2][1],
                c+=1
            else:
                print l[i][1],
        print
        exit()

print 'NO'


def qsort(array):
    less = []
    equal = []
    greater = []

    if len(array) > 1:
        pivot = array[0][0]
        for x in array:
            if x[0] < pivot:
                less.append(x)
            if x[0] == pivot:
                equal.append(x)
            if x[0] > pivot:
                greater.append(x)
        return qsort(less)+equal+qsort(greater)
    else:
        return array

n = int(raw_input())
h = raw_input().split()
h = map(int, h)

tup = []
for i in range(n):
	tupa = (h[i], i + 1)
	tup.append(tupa)

tup = qsort(tup)

iter1 = 0
parou2 = 0
geradas = []
index = -2, -2
while True:
	for j in range(n - 1):
		if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
			iter1 += 1
			index = (j, j+1)
			break
	parou2 += 1
	if parou2 == 3: break

if iter1 == 3:
	print "YES"

	parou = 0
	geradas = []
	index = -2, -2
	while True:
	        for j in range(n - 1):
	                if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
	                        tup[j], tup[j + 1] = tup[j + 1], tup[j]
	                        parou += 1
	                        index = (j, j+1)
	                        break
	        l = []
	        for k in range(n):
	                l.append(tup[k][1])
		l = map(str, l)
		print ' '.join(l)
	        if parou == 3: break
else:
	print "NO"


n = int(raw_input())
h = raw_input().split()
h = map(int, h)

tup = []
for i in range(n):
	tupa = (h[i], i + 1)
	tup.append(tupa)

tup.sort(key = lambda x : x[0])

iter1 = 0
parou2 = 0
index = -2, -2
for k in range(3):
	for j in range(n - 1):
		if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
			iter1 += 1
			index = (j, j+1)
			break

if iter1 == 3:
	print "YES"

	index = -2, -2
	for f in range(3):
	        for j in range(n - 1):
	                if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
	                        tup[j], tup[j + 1] = tup[j + 1], tup[j]
	                        index = (j, j+1)
	                        break
	        l = []
	        for k in range(n):
	                l.append(tup[k][1])
		l = map(str, l)
		print ' '.join(l)
else:
	print "NO"


n = int(raw_input())
h = raw_input().split()
h = map(int, h)

tup = []
for i in range(n):
    tupa = (h[i], i + 1)
    tup.append(tupa)

tup.sort(key = lambda x : x[0])

iter1 = 0
parou2 = 0
index = -2, -2
for k in range(3):
    for j in range(n - 1):
        if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
            iter1 += 1
            index = (j, j+1)
            break

if iter1 == 3:
    print "YES"

    index = -2, -2
    for f in range(3):
            for j in range(n - 1):
                    if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
                            tup[j], tup[j + 1] = tup[j + 1], tup[j]
                            index = (j, j+1)
                            break
            l = []
            for k in range(n):
                    l.append(tup[k][1])
        l = map(str, l)
        print ' '.join(l)
else:
    print "NO"


n = int(raw_input())
h = raw_input().split()
h = map(int, h)

tup = []
for i in range(n):
    tupa = (h[i], i + 1)
    tup.append(tupa)

tup.sort(key = lambda x : x[0])

iter1 = 0
parou2 = 0
index = -2, -2
for k in range(3):
    for j in range(n - 1):
        if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
            iter1 += 1
            index = (j, j+1)
            break

if iter1 == 3:
    print "YES"

    index = -2, -2
    for f in range(3):
            for j in range(n - 1):
                    if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
                            tup[j], tup[j + 1] = tup[j + 1], tup[j]
                            index = (j, j+1)
                            break
            l = []
            for k in range(n):
                    l.append(tup[k][1])
            l = map(str, l)
            print ' '.join(l)
else:
    print "NO"


def qsort(array):
    less = []
    equal = []
    greater = []

    if len(array) > 1:
        pivot = array[0][0]
        for x in array:
            if x[0] < pivot:
                less.append(x)
            if x[0] == pivot:
                equal.append(x)
            if x[0] > pivot:
                greater.append(x)
        return qsort(less)+equal+qsort(greater)
    else:
        return array

n = int(raw_input())
h = raw_input().split()
h = map(int, h)

tup = []
for i in range(n):
	tupa = (h[i], i + 1)
	tup.append(tupa)

tup = qsort(tup)

iter1 = 0
parou2 = 0
index = -2, -2
for k in range(3):
	for j in range(n - 1):
		if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
			iter1 += 1
			index = (j, j+1)
			break

if iter1 == 3:
	print "YES"

	index = -2, -2
	for f in range(3):
	        for j in range(n - 1):
	                if tup[j][0] == tup[j + 1][0] and (j, j + 1) != index:
	                        tup[j], tup[j + 1] = tup[j + 1], tup[j]
	                        index = (j, j+1)
	                        break
	        l = []
	        for k in range(n):
	                l.append(tup[k][1])
		l = map(str, l)
		print ' '.join(l)
else:
	print "NO"


def show_tasks(tasks):
    result = ""
    for i in xrange(len(tasks)):
        if i != len(tasks) - 1:
            result += str(tasks[i][1]) + " "
        else:
            result += str(tasks[i][1])

    return result

def get_key(item):
    return item[0]

n = int(raw_input())
tasks = map(int, raw_input().split())

for i in xrange(len(tasks)):
    tasks[i] = (tasks[i], i + 1)

tasks = sorted(tasks, key = get_key)

swap1, swap2 = [], []
possible_swaps = 0
for i in xrange(1, len(tasks)):
    if tasks[i - 1][0] == tasks[i][0]:
        possible_swaps += 1

        if swap1 == []:
            swap1 = [i - 1, i]
        else:
            swap2 = [i - 1, i]

if possible_swaps < 2:
    print "NO"
else:
    print "YES"
    print show_tasks(tasks)

    tasks_aux = tasks
    tasks_aux[swap1[0]], tasks_aux[swap1[1]] = tasks_aux[swap1[1]], tasks_aux[swap1[0]]

    print show_tasks(tasks_aux)

    tasks_aux = tasks
    tasks_aux[swap2[0]], tasks_aux[swap2[1]] = tasks_aux[swap2[1]], tasks_aux[swap2[0]]
    print show_tasks(tasks_aux)


def show_tasks(tasks):
    result = ""
    for i in xrange(len(tasks)):
        if i != len(tasks) - 1:
            result += str(tasks[i][1]) + " "
        else:
            result += str(tasks[i][1])

    return result

def getKey(item):
    return item[0]

n = int(raw_input())
tasks = map(int, raw_input().split())

for i in xrange(len(tasks)):
    tasks[i] = (tasks[i], i + 1)

tasks = sorted(tasks, key = getKey)

swap1, swap2 = [], []
possible_swaps = 0
for i in xrange(1, len(tasks)):
    if tasks[i - 1][0] == tasks[i][0]:
        possible_swaps += 1

        if swap1 == []:
            swap1 = [i - 1, i]
        else:
            swap2 = [i - 1, i]

if possible_swaps < 2:
    print "NO"
else:
    print "YES"
    print show_tasks(tasks)

    tasks_aux = tasks
    tasks_aux[swap1[0]], tasks_aux[swap1[1]] = tasks_aux[swap1[1]], tasks_aux[swap1[0]]

    print show_tasks(tasks_aux)

    tasks_aux = tasks
    tasks_aux[swap2[0]], tasks_aux[swap2[1]] = tasks_aux[swap2[1]], tasks_aux[swap2[0]]
    print show_tasks(tasks_aux)


n = int(raw_input())
a = map(int, raw_input().split())
a.sort()
b = []
for i in range(n):
	b.append([a[i], i+1])
b.sort(key = lambda x:x[0])

x = 0
ans = []
li = []
for i in b:
	li.append(str(i[1]))
ans.append(li)
for i in range(n-1):
	if x >= 2:
		break
	if b[i][0] == b[i+1][0]:
		b[i][1], b[i+1][1] = b[i+1][1], b[i][1]
		tmp = []
		for j in b:
			tmp.append(str(j[1]))
		ans.append(tmp)
		x += 1
if x >=2 :
	print 'YES'
	for i in ans:
		print ' '.join(i)
else:
	print 'NO'


n = int(raw_input())
a = map(int, raw_input().split())
b = []
for i in range(n):
	b.append([a[i], i+1])
b.sort(key = lambda x:x[0])
print b
x = 0
ans = []
li = []
for i in b:
	li.append(str(i[1]))
ans.append(li)
for i in range(n-1):
	if x >= 2:
		break
	if b[i][0] == b[i+1][0]:
		b[i][1], b[i+1][1] = b[i+1][1], b[i][1]
		tmp = []
		for j in b:
			tmp.append(str(j[1]))
		ans.append(tmp)
		x += 1
if x >=2 :
	print 'YES'
	for i in ans:
		print ' '.join(i)
else:
	print 'NO'


n = int(raw_input())
a = map(int, raw_input().split())
b = []
for i in range(n):
	b.append([a[i], i+1])
b.sort(key = lambda x:x[0])
x = 0
ans = []
li = []
for i in b:
	li.append(str(i[1]))
ans.append(li)
for i in range(n-1):
	if x >= 2:
		break
	if b[i][0] == b[i+1][0]:
		b[i][1], b[i+1][1] = b[i+1][1], b[i][1]
		tmp = []
		for j in b:
			tmp.append(str(j[1]))
		ans.append(tmp)
		x += 1
if x >=2 :
	print 'YES'
	for i in ans:
		print ' '.join(i)
else:
	print 'NO'


n, m = map(int, raw_input().split())
a = list(map(int, raw_input().split()))
a.sort()
ans = 0
i = n-1
while i >=0 :
	ans = ans + (a[i]-1)*2
	i = i - m
print ans


n = int(raw_input())

diff = [int(x) for x in raw_input().split()]
inds = []

for i in range(n):
    inds.append((diff[i],i))

inds.sort()

resp = []
resp.append([x[1]+1 for x in inds])

cont = 0

for i in range(n-1):
    if inds[i][0]==inds[i+1][0]:
        cont+=1
        temp = inds[i]
        inds[i] = inds[i+1]
        inds[i+1] = temp
        resp.append([x[1]+1 for x in inds])
        if cont==2:
            break

if cont==2:
    print "YES"
    for i in resp:
        print ' '.join(map(str,i))
else:
    print "NO"


def printing(a, n):
    string = ""
    for i in range(n-1):
        string+=str(a[i][1]+1)+" "
    string += str(a[n-1][1]+1)
    print string
    return

n = int(raw_input(""))
a = raw_input("").split(" ")
#a = map(lambda x: int(x), a)
for i in range(n):
   a[i] = [int(a[i]), i]
#print a
a.sort()
i = 2
k = -1
while i < n:
    if  a[i][0]==a[i-1][0] and a[i][0] == a[i-2][0]:
        k = i
        break
    i+=1
if k == -1:
    i = 1
    l = -1
    m = -1
    while i<n:
        if a[i][0] == a[i-1][0]:
            if l == -1:
                l = i
            else:
                m = i
                break
        i+=1
if k!=-1:
    print "YES"
    printing(a, n)
    #print a
    a[k-2], a[k-1] = a[k-1], a[k-2]
    #print a
    printing(a, n)
    a[k-1], a[k] = a[k], a[k-1]
    #print a
    printing(a, n)
elif m!=-1:
    print "YES"
    printing(a, n)
    a[l], a[l-1] = a[l-1], a[l]
    printing(a, n)
    a[m], a[m-1] = a[m-1], a[m]
    printing(a, n)
else:
    print "NO"


def printing(a, n):
    string = ""
    for i in range(n-1):
        string+=str(a[i][1]+1)+" "
    string += str(a[n-1][1]+1)
    print string
    return

n = int(raw_input(""))
a = raw_input("").split(" ")
#a = map(lambda x: int(x), a)
for i in range(n):
   a[i] = [int(a[i]), i]
#print a
a.sort()
i = 2
k = -1
while i < n:
    if  a[i][0]==a[i-1][0] and a[i][0] == a[i-2][0]:
        k = i
        break
    i+=1
if k == -1:
    i = 1
    l = -1
    m = -1
    while i<n:
        if a[i][0] == a[i-1][0]:
            if l == -1:
                l = i
            else:
                m = i
                break
        i+=1
if k!=-1:
    print "YES"
    printing(a, n)
    a[k-2], a[k-1] = a[k-1], a[k-2]
    printing(a, n)
    a[k-1], a[k] = a[k-1], a[k]
    printing(a, n)
elif m!=-1:
    print "YES"
    printing(a, n)
    a[l], a[l-1] = a[l-1], a[l]
    printing(a, n)
    a[m], a[m-1] = a[m-1], a[m]
    printing(a, n)
else:
    print "NO"


N = int(raw_input())

h = map(int, raw_input().split())
h = sorted(enumerate(h), key=lambda x:x[1])

if N < 3:
    print 'NO'
else:
    ans1 = str(h[0][0]+1)+' '
    ans2 = ''
    ans3 = ''

    ans2Done = False
    ans3Done = False

    prev = h[0][1]
    for i in range(1,N):
        ans1 += str(h[i][0]+1)+' '
        if h[i][1] == prev and not ans2Done:
            ans2 += str(h[i][0]+1)+' '
            ans2 += str(h[i-1][0]+1)+' '
            ans2Done = True
            ans3 += str(h[i-1][0]+1)+' '
        elif ans2Done and not ans3Done and h[i][1] == prev:
            ans3 += str(h[i][0]+1)+' '
            ans3 += str(h[i-1][0]+1)+' '
            ans3Done = True
            ans2 += str(h[i-1][0]+1)+' '
        elif not ans2Done and not ans3Done:
            ans2 += str(h[i-1][0]+1)+' '
            ans3 += str(h[i-1][0]+1)+' '
        elif ans2Done and not ans3Done:
            ans2 += str(h[i][0]+1)+' '
            ans3 += str(h[i-1][0]+1)+' '
        elif ans2Done and ans3Done:
            ans2 += str(h[i][0]+1)+' '
            ans3 += str(h[i][0]+1)+' '
        prev = h[i][1]
    if ans1 == ans2 or ans1 == ans3 or ans2 == ans3 or not ans2Done or not ans3Done:
        print 'NO'
    else:
        print 'YES'
        print ans1.strip()
        print ans2.strip()
        print ans3.strip()


N = int(raw_input())

h = map(int, raw_input().split())
h = sorted(enumerate(h), key=lambda x:x[1])

if N < 3:
    print 'NO'
else:
    ans1 = str(h[0][0]+1)+' '
    ans2 = ''
    ans3 = ''

    ans2Done = False
    ans3Done = False

    prev = h[0][1]
    for i in range(1,N):
        ans1 += str(h[i][0]+1)+' '
        if h[i][1] == prev and not ans2Done:
            ans2 += str(h[i][0]+1)+' '
            ans2 += str(h[i-1][0]+1)+' '
            ans2Done = True
            ans3 += str(h[i-1][0]+1)+' '
        elif ans2Done and not ans3Done and h[i][1] == prev:
            ans3 += str(h[i][0]+1)+' '
            ans3 += str(h[i-1][0]+1)+' '
            ans3Done = True
            ans2 += str(h[i][0]+1)+' '
        elif not ans2Done and not ans3Done:
            ans2 += str(h[i-1][0]+1)+' '
            ans3 += str(h[i-1][0]+1)+' '
        elif ans2Done and not ans3Done:
            ans2 += str(h[i][0]+1)+' '
            ans3 += str(h[i-1][0]+1)+' '
        elif ans2Done and ans3Done:
            ans2 += str(h[i][0]+1)+' '
            ans3 += str(h[i][0]+1)+' '
        prev = h[i][1]
    if ans1 == ans2 or ans1 == ans3 or ans2 == ans3 or not ans2Done or not ans3Done:
        print 'NO'
    else:
        print 'YES'
        print ans1.strip()
        print ans2.strip()
        print ans3.strip()


n = int(raw_input())
hs = map(int, raw_input().split())
diff = 0
hs = zip(hs, range(1, n+1))
hs.sort()
p1, p2, p3 = [], [], []
for i in range(n):
    d, p = hs[i]
    if i == 0 or d != hs[i-1][0]:
        p1.append(p)
        p2.append(p)
        p3.append(p)
    elif diff == 0:
        po = p1[-1]
        p1.append(p)
        p2[-1] = p
        p2.append(po)
        p3[-1] = p
        p3.append(po)
        diff += 1
    elif diff == 1:
        po = p2[-1]
        p1.append(p)
        p2.append(p)
        p3[-1] = p
        p3.append(po)
        diff += 1
    else:
        p1.append(p)
        p2.append(p)
        p3.append(p)
if diff != 2:
    print "NO"
else:
    print "YES"
    print " ".join(str(x) for x in p1)
    print " ".join(str(x) for x in p2)
    print " ".join(str(x) for x in p3)


n = int(raw_input())

class Task(object):
    def __init__(self,d,n):
        self.d = d
        self.n = n
    def __str__(self):
        print "%d %d" %(self.d,self.n)

tasks = []

p = map(int,raw_input().split())

for i,x in enumerate(p):
    tasks.append(Task(x,i+1))

tasks.sort(key=lambda x : x.d)
ans = [[x.n for x in tasks]]

for i in range(len(tasks)-1):
    if tasks[i].d == tasks[i+1].d:
        tasks[i],tasks[i+1] = tasks[i+1],tasks[i]
        ans.append([x.n for x in tasks])
    if len(ans) == 3:
        break

if len(ans) == 3:
    print "YES"
    for i in xrange(3):
        print " ".join(map(str,ans[i]))
else:
    print "NO"


from collections import Counter

def find_keys(counts, min_value, key_count):
    possible_items = []
    for key, value in counts.iteritems():
        if value >= min_value:
            possible_items.append(key)
    return possible_items[:key_count]

def find_indices(order, enumeration, key):
    permutation_places = []
    for order_index, enumeration_index in enumerate(order):
        if enumeration[enumeration_index] == key:
            permutation_places.append(order_index)
    return permutation_places

def generate_plan(order, pair=None):
    plan = map(lambda x: x + 1, order)
    if pair is None:
        return plan
    plan[pair[0]], plan[pair[1]] = plan[pair[1]], plan[pair[0]]
    return plan

def generate_full_plan(order, indices_1, indices_2):
    plan = []
    plan.append(generate_plan(order))
    plan.append(generate_plan(order, indices_1))
    plan.append(generate_plan(order, indices_2))
    return plan

def get_plan(items):
    counts = Counter(items)
    count_counts = Counter(counts.values())

    enumeration = dict(enumerate(items))
    order = sorted(enumeration, key=enumeration.__getitem__)

    if any(map(lambda occurence: occurence >= 3, count_counts.keys())):
        permutation_item = find_keys(counts, 3, 1)[0]
        permutation_places = find_indices(order, enumeration, permutation_item)[:3]
        indices_1 = permutation_places[0:2]
        indices_2 = permutation_places[1:3]
        return generate_full_plan(order, indices_1, indices_2)
    elif count_counts[2] >= 2:
        permutation_item_1, permutation_item_2 = find_keys(counts, 2, 2)
        indices_1 = find_indices(order, enumeration, permutation_item_1)
        indices_2 = find_indices(order, enumeration, permutation_item_2)
        return generate_full_plan(order, indices_1, indices_2)
    return None

def main():
    item_count = int(raw_input())
    items = map(int, raw_input().split())
    plan = get_plan(items)
    if plan is not None:
        print "YES"
        for subplan in plan:
            print " ".join(map(str, subplan))
    else:
        print "NO"

if __name__ == '__main__':
    main()


def f2():
    from collections import Counter
    N = int(raw_input())
    x = map(int, raw_input().split())
    c = Counter(x)
    max_c = max(c.values())
    if max_c == 1:
        print 'NO'
    elif max_c == 2:
        set_two = set()
        for k in c:
            if c[k] == 2 and len(set_two) < 2:
                set_two.add(k)
        if len(set_two) < 2:
            print 'NO'
        else:
            print 'YES'
            set_two = list(set_two)
            stuff = [[], []]
            for i in range(N):
                if x[i] == set_two[0]:
                    stuff[0].append(i)
                if x[i] == set_two[1]:
                    stuff[1].append(i)
            cs = list(x)
            cs[stuff[0][0]] += .1
            cs[stuff[1][0]] += .1
            print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
            cs = list(x)
            cs[stuff[0][1]] += .1
            cs[stuff[1][0]] += .1
            print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
            cs = list(x)
            cs[stuff[0][0]] += .1
            cs[stuff[1][1]] += .1
            print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
    else:
        print 'YES'
        let = 2
        for k in c:
            if c[k] >= 3:
                let = k
        stuff = []
        for i in range(N):
            if x[i] == let:
                stuff.append(i)
        cs = list(x)
        cs[stuff[0]] = .1
        print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
        cs = list(x)
        cs[stuff[1]] += .1
        print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
        cs = list(x)
        cs[stuff[2]] += .1
        print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))

f2()


def f2():
    from collections import Counter
    N = int(raw_input())
    x = map(int, raw_input().split())
    c = Counter(x)
    max_c = max(c.values())
    if max_c == 1:
        print 'NO'
    elif max_c == 2:
        set_two = set()
        for k in c:
            if c[k] == 2 and len(set_two) < 2:
                set_two.add(k)
        if len(set_two) < 2:
            print 'NO'
        else:
            print 'YES'
            set_two = list(set_two)
            stuff = [[], []]
            for i in range(N):
                if x[i] == set_two[0]:
                    stuff[0].append(i)
                if x[i] == set_two[1]:
                    stuff[1].append(i)
            cs = list(x)
            cs[stuff[0][0]] += .1
            cs[stuff[1][0]] += .1
            print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
            cs = list(x)
            cs[stuff[0][1]] += .1
            cs[stuff[1][0]] += .1
            print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
            cs = list(x)
            cs[stuff[0][0]] += .1
            cs[stuff[1][1]] += .1
            print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
    else:
        print 'YES'
        let = 2
        for k in c:
            if c[k] >= 3:
                let = k
        stuff = []
        for i in range(N):
            if x[i] == let:
                stuff.append(i)
        cs = list(x)
        cs[stuff[0]] += .1
        print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
        cs = list(x)
        cs[stuff[1]] += .1
        print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
        cs = list(x)
        cs[stuff[2]] += .1
        print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))

f2()


def f2():
    from collections import Counter
    N = int(raw_input())
    x = map(int, raw_input().split())
    c = Counter(x)
    max_c = max(c.values())
    if max_c == 1:
        print 'NO'
    elif max_c == 2:
        set_two = set()
        for k in c:
            if c[k] == 2 and len(set_two) < 2:
                set_two.add(k)
        if len(set_two) < 2:
            print 'NO'
        else:
            set_two = list(set_two)
            stuff = [[], []]
            for i in range(N):
                if x[i] == set_two[0]:
                    stuff[0].append(i)
                if x[i] == set_two[1]:
                    stuff[1].append(i)
            cs = list(x)
            cs[stuff[0][0]] += .1
            cs[stuff[1][0]] += .1
            print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
            cs = list(x)
            cs[stuff[0][1]] += .1
            cs[stuff[1][0]] += .1
            print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
            cs = list(x)
            cs[stuff[0][0]] += .1
            cs[stuff[1][1]] += .1
            print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
    else:
        let = 2
        for k in c:
            if c[k] >= 3:
                let = k
        stuff = []
        for i in range(N):
            if x[i] == let:
                stuff.append(i)
        cs = list(x)
        cs[stuff[0]] = .1
        print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
        cs = list(x)
        cs[stuff[1]] += .1
        print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))
        cs = list(x)
        cs[stuff[2]] += .1
        print " ".join(map(str, sorted(range(1, N + 1), key=lambda i: cs[i - 1])))

f2()


n = int(raw_input())
a = map(int,raw_input().split())
from collections import Counter
import itertools
so = Counter(a).most_common()
check = 1
for s in so:
    check *= s[1]
if check<3:
    print "NO"
else:
    print "YES"
    so = sorted(so)
    #print so
    ans = []
    for s in so:
        ans.append([1+i for i, x in enumerate(a) if x == s[0]])

   # print ans
    #c = [[0 for _ in xrange(n)] for _ in xrange(3)]
    for c in range(3):
        flag = True
        for k in ans:
            if len(k) == 1:
                print k[0],
            elif c==0:
                print k[0],k[1],
                for kk in range(2,len(k)):
                    print k[kk],
            elif c==1:
                print k[1],k[0],
                for kk in range(2,len(k)):
                    print k[kk],
            elif c==2 and flag:
                print k[0],k[1],
                flag = False
                for kk in range(2,len(k)):
                    print k[kk],
            elif c==2 and not flag:
                print k[1],k[0],
                flag = False
                for kk in range(2,len(k)):
                    print k[kk],
        print


n = int(raw_input())
a = map(int,raw_input().split())
from collections import Counter
import itertools
so = Counter(a).most_common()
check = 1
for s in so:
    check *= s[1]
if check<3:
    print "NO"
else:
    print "YES"
    ans = []
    for s in so:
        ans.append([i for i, x in enumerate(a) if x == s[0]])
    ans2 = []
    for an in ans:
        ans2.append(list(itertools.permutations(an)))
    #print ans2
    fina = list(itertools.product(*ans2))
    c = 0
    for i in fina:
        if c==3:
            break
        for j in i:
            for k in j:
                print k+1,
        c += 1
        print


n = int(raw_input())
a = map(int,raw_input().split())
from collections import Counter
import itertools
so = Counter(a).most_common()
check = 1
for s in so:
    check *= s[1]
if check<3:
    print "NO"
else:
    print "YES"
    so = sorted(so)
    #print so
    ans = []
    for s in so:
        ans.append([1+i for i, x in enumerate(a) if x == s[0]])

   # print ans
    #c = [[0 for _ in xrange(n)] for _ in xrange(3)]
    for c in range(3):
        flag = True
        for k in ans:
            if len(k) == 1:
                print k[0],
            elif len(k)==2 and c==0:
                print k[0],k[1],
                for kk in range(2,len(k)):
                    print k[kk],
            elif len(k)==2 and c==1:
                print k[1],k[0],
                for kk in range(2,len(k)):
                    print k[kk],
            elif len(k)==2 and c==2 and flag:
                print k[0],k[1],
                flag = False
                for kk in range(2,len(k)):
                    print k[kk],
            elif len(k)==2 and c==2 and not flag:
                print k[1],k[0],
                flag = False
                for kk in range(2,len(k)):
                    print k[kk],
            elif len(k)>=3 and c==0:
                print k[0],k[1],k[2],
                for kk in range(3,len(k)):
                    print k[kk],
            elif len(k)>=3 and c==1:
                print k[0],k[2],k[1],
                for kk in range(3,len(k)):
                    print k[kk],
            elif len(k)>=3 and c==2:
                print k[1],k[0],k[2],
                for kk in range(3,len(k)):
                    print k[kk],
        print


n = int(raw_input())
a = map(int,raw_input().split())
from collections import Counter
import itertools
so = Counter(a).most_common()
check = 1
for s in so:
    check *= s[1]
if check<3:
    print "NO"
else:
    print "YES"
    so = sorted(so)
    #print so
    ans = []
    for s in so:
        ans.append([i for i, x in enumerate(a) if x == s[0]])
    #ans = sorted(ans)
    #print ans
    ans2 = []
    for an in ans:
        ans2.append(list(itertools.permutations(an)))
    #print ans2
    fina = list(itertools.product(*ans2))
    c = 0
    for i in fina:
        if c==3:
            break
        for j in i:
            for k in j:
                print k+1,
        c += 1
        print


'''import itertools
n=int(raw_input())
m=map(int,raw_input().split())
m.sort()
a=()
for x in range(n):
    a=a+(m[x],)
n=list(itertools.permutations(m))
#print n.count(a)
if n.count(a)>=3:
    print "Done" '''

n=int(raw_input())
m=map(int,raw_input().split())
cnt=1
for x in set(m):
    cnt*=m.count(x)
if cnt<3:
    print "NO"
    exit()
print "YES"
l=[]
b=sorted([(m[i],i) for i in range(n)])
for i in range (0,len(b)-1):
    if b[i][0]==b[i+1][0]:
        l.append(i)
        if len(l)==2:
            break
print " ".join([str(x[1]+1) for x in b])
b[l[0]],b[l[0]+1]=b[l[0]+1],b[l[0]]
print " ".join([str(x[1]+1) for x in b])
b[l[1]],b[l[1]+1]=b[l[1]+1],b[l[1]]
print " ".join([str(x[1]+1) for x in b])


'''import itertools
n=int(raw_input())
m=map(int,raw_input().split())
m.sort()
a=()
for x in range(n):
    a=a+(m[x],)
n=list(itertools.permutations(m))
#print n.count(a)
if n.count(a)>=3:
    print "Done" '''

n=int(raw_input())
m=map(int,raw_input().split())
cnt=1
for x in set(m):
    cnt*=m.count(x)
if cnt<3:
    print "NO"
    exit()
print "YES"
l=[]
b=sorted([(m[i],i) for i in range(n)])
for i in range (0,len(b)-1):
    if b[i][0]==b[i][0]:
        l.append(i)
        if len(l)==2:
            break
print " ".join([str(x[1]+1) for x in b])
b[l[0]],b[l[0]+1]=b[l[0]+1],b[l[0]]
print " ".join([str(x[1]+1) for x in b])
b[l[1]],b[l[1]+1]=b[l[1]+1],b[l[1]]
print " ".join([str(x[1]+1) for x in b])


import math
n = int(raw_input())
#a = [int(raw_input())for i in xrange(n)]
a = [int(x)for x in raw_input().split(' ')]
#a = [[int(x)for x in raw_input().split(' ')]for i in xrange(n)]

sa = sorted(a)
at = {}
for i in xrange(n):
    try:
        at[a[i]].append(i+1)
    except:
        at.update({a[i]: [i+1]})
r = 1
for x in at:
    r *= len(at[x])
if r < 3:
    print 'NO'
    quit()
print 'YES'
print ' '.join([' '.join([str(i)for i in x]) for x in at.values()])
asd=0
for c1 in at.keys():
    if len(at[c1]) > 1:
        at[c1][0], at[c1][1] = at[c1][1], at[c1][0]
        break
    asd += 1
print ' '.join([' '.join([str(i)for i in x]) for x in at.values()])
for c2 in at.keys()[asd:]:
    if len(at[c2]) > 1 and c2 > c1:
        at[c2][0], at[c2][1] = at[c2][1], at[c2][0]
        break
    elif len(at[c2]) > 2:
        at[c2][1], at[c2][2] = at[c2][2], at[c2][1]
        break
print ' '.join([' '.join([str(i)for i in x]) for x in at.values()])


import math
import operator
n = int(raw_input())
a = map(int, raw_input().split())

sa = sorted({i: a[i] for i in xrange(n)}.items(), key=operator.itemgetter(1))
ans = []
for i in xrange(1, n):
    if sa[i][1] == sa[i - 1][1]:
        t = [sa[j][0] + 1 for j in xrange(n)]
        t[i], t[i - 1] = t[i - 1], t[i]
        ans.append(t)
        if len(ans) > 0:
            t = list(ans[-1])
            t[i], t[i - 1] = t[i - 1], t[i]
            ans.append(t)
    if len(ans) > 2:
        print 'YES'
        print '\n'.join([' '.join(map(str, x)) for x in ans[:3]])
        quit()

print 'NO'


#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = int(raw_input())
h = map(int, raw_input().split())

hh = [(h[i],i) for i in range(len(h))]

hh.sort()

d2,d3,d22 = False, False, False
i1,i2,i3,i4 = [0]*4
c = 1
val21,val22,val3 = 0,0,0

if len(hh)<=2:
    print "NO"
    exit()

for i in range(1,len(hh)):
    if hh[i][0] == hh[i-1][0]:
        c+=1
        if c >= 3:
            val3 = hh[i][0]
            i1,i2,i3 = hh[i-2][1], hh[i-1][1], hh[i][1]
            d3 = True
            break

        if not d2 and c == 2:
            val21 = hh[i][0]
            i1,i2 = hh[i-1][1], hh[i][1]
            d2 = True
            continue

        if d2 and c == 2:
            val22 = hh[i][0]
            i3,i4 = hh[i-1][1], hh[i][1]
            d22 = True
            break

    else:
        c = 1

if d3:
    print "YES"
    perms = [[i1,i2,i3],[i2,i1,i3],[i3,i2,i1]]
    for r in range(3):
        res = []
        done = False
        t = 0
        for i in range(len(hh)):
            if t<3 and hh[i][0] == val3:
                res.append(perms[r][t])
                t += 1
            else:
                res.append(hh[i][1])
        print ' '.join(map(lambda x: str(x+1), res))
elif d22:
    print "YES"
    perms = [ [i1,i2,i3,i4],[i2,i1,i3,i4],[i1,i2,i4,i3] ]

    for r in range(3):
        res = []
        done = False
        t = 0
        for i in range(len(hh)):
            if t<4 and (hh[i][0] == val21 or hh[i][0] == val22):
                res.append(perms[r][t])
                t += 1
            else:
                res.append(hh[i][1])
        print ' '.join(map(lambda x: str(x+1), res))
else:
    print "NO"


n=input()
li=map(int,raw_input().split())
t=()
for i in xrange(n):
	t+=((li[i],i+1),)
t=sorted(t)
l=0
for i in xrange(1,n):
	if(t[i][0]==t[i-1][0]):
		l+=1
if(l<2):
	print "NO"
else:
	print "YES"
	for i in xrange(n):
		print t[i][1],
	print
	flag=0
	for i in xrange(1,n):
		if(t[i][0]==t[i-1][0] and flag==0):
			t[i],t[i-1]=t[i-1],t[i]
			print t[i-1][1],
			p=i
			flag=1
		else:
			print t[i-1][1],
	print t[i][1]
	flag=0
	for i in xrange(1,n):
		if(t[i][0]==t[i-1][0] and i!=p and flag==0):
			t[i],t[i-1]=t[i-1],t[i]
			print t[i-1][1],
			flag=1
		else:
			print t[i-1][1],
	print t[i][1]


t=input()
x=raw_input()
a=[]
a=map(int,x.split())
d={}
b=[]
l=len(a)
for i in range(0,l):
    if a[i] not in d:
        b.append(a[i])
        d[a[i]]=1
    else:
        d[a[i]]=d[a[i]]+1
r=len(b)
if l-r>=2:
    print "YES"
    p=[]
    for i in range(0,r):
        if d[b[i]]>1:
            p.append(b[i])
            if len(p)==2:
                break
    c=[]
    for i in range(0,l):
        c.append([a[i],i+1])
    c.sort()
    s=""
    for i in range(0,l):
        s=s+str(c[i][1])
        s=s+" "
    print s
    if len(p)==2:
        s=""
        for i in range(0,l):
            if p[0]==c[i][0]:
                break
        c[i],c[i+1]=c[i+1],c[i]
        for i in range(0,l):
            s=s+str(c[i][1])
            s=s+" "
        print s
        for i in range(0,l):
            if p[1]==c[i][0]:
                break
        c[i],c[i+1]=c[i+1],c[i]
        s=""
        for i in range(0,l):
            s=s+str(c[i][1])
            s=s+" "
        print s
    else:
        for i in range(0,l):
            if p[0]==c[i][0]:
                break
        c[i],c[i+1]=c[i+1],c[i]
        s=""
        for j in range(0,l):
            s=s+str(c[j][1])
            s=s+" "
        print s
        c[i],c[i+2]=c[i+2],c[i]
        s=""
        for i in range(0,l):
            s=s+str(c[i][1])
            s=s+" "
        print s

else:
    print "NO"


import sys

def print_ans(lst):
  for n, i in lst:
    print i,
  print

sys.stdin.readline()
ns = map(int, sys.stdin.readline().split())
res = []
for i, n in enumerate(ns):
  res.append((n, i+1))
res.sort(key=lambda (a,b): a)

dup_idx = -1
dup_num = -1
dup_count = 1
for idx, (n, i) in enumerate(res):
  if dup_num == n:
    dup_count += 1
    if dup_count == 2:
      if dup_idx >= 0:
        # second time
        ans2 = res[:]
        ans2[dup_idx-1], ans2[dup_idx] = ans2[dup_idx], ans2[dup_idx-1]
        ans3 = res[:]
        ans3[idx-1], ans3[idx] = ans3[idx], ans3[idx-1]
        print "YES"
        print_ans(res)
        print_ans(ans2)
        print_ans(ans3)
        exit()
      else:
        dup_idx = idx
    elif dup_count == 3:
      # three in a row
      ans2 = res[:]
      ans2[idx-2], ans2[idx] = ans2[idx], ans2[idx-2]
      ans3 = res[:]
      ans3[idx-1], ans3[idx] = ans3[idx], ans3[idx-1]
      print "YES"
      print_ans(res)
      print_ans(ans2)
      print_ans(ans3)
      exit()
  else:
    # reset
    dup_num = n
    dup_count = 1

print "NO"


import sys
import copy
from itertools import permutations

def main():
    n = int(sys.stdin.readline())
    h = map(int, sys.stdin.readline().split())
    d = {}
    for j, i in enumerate(h):
        if i in d:
            d[i].append(j+1)
        else:
            d[i] = [j+1]
    if len(d) + 2 > n:
        print "NO"
        return
    print "YES"
    s = [item[1] for item in sorted(d.items())]
    def enum(i, n, pre, c):
        if i == len(h):
            print " ".join(map(str, pre))
            c[0] += 1
            if c[0] == 3:
                sys.exit()
            return
        # print 'i', i, 'n', n
        for p in permutations(s[n]):
            enum(i+len(s[n]), n+1, pre + list(p), c)
    enum(0, 0, [], [0])

if __name__ == '__main__':
    main()


import sys
from itertools import permutations

def main():
    n = int(sys.stdin.readline())
    h = map(int, sys.stdin.readline().split())
    d = {}
    for j, i in enumerate(h):
        if i in d:
            d[i].append(j+1)
        else:
            d[i] = [j+1]
    if len(d) + 2 > n:
        print "NO"
        return
    print "YES"
    s = [item[1] for item in sorted(d.items())]
    def enum(i, n, pre, c):
        q = []
        q.append((i, n, pre, c))
        while len(q):
            i, n, pre, c = q.pop()
            if i == len(h) or n == len(s):
                print " ".join(map(str, pre))
                c[0] += 1
                if c[0] == 3:
                    break
            else:
                cc = 0
                for p in permutations(s[n]):
                    if cc > 5:
                        break
                    q.append((i+len(s[n]), n+1, pre + list(p), c))
                    cc += 1
    enum(0, 0, [], [0])

if __name__ == '__main__':
    main()


import sys
from itertools import permutations

def main():
    n = int(sys.stdin.readline())
    h = map(int, sys.stdin.readline().split())
    d = {}
    for j, i in enumerate(h):
        if i in d:
            d[i].append(j+1)
        else:
            d[i] = [j+1]
    if len(d) + 2 > n:
        print "NO"
        return
    print "YES"
    s = [item[1] for item in sorted(d.items())]
    def enum(i, n, pre, c):
        q = []
        q.append((i, n, pre, c))
        while len(q):
            i, n, pre, c = q.pop()
            if i == len(h) or n == len(s):
                print " ".join(map(str, pre))
                c[0] += 1
                if c[0] == 3:
                    break
            else:
                for p in permutations(s[n]):
                    q.append((i+len(s[n]), n+1, pre + list(p), c))
    enum(0, 0, [], [0])

if __name__ == '__main__':
    main()


import sys
import copy
from itertools import permutations

def main():
    n = int(sys.stdin.readline())
    h = map(int, sys.stdin.readline().split())
    d = {}
    for j, i in enumerate(h):
        if i in d:
            d[i].append(j+1)
        else:
            d[i] = [j+1]
    if len(d) + 2 > n:
        print "NO"
        return

    s = [item[1] for item in sorted(d.items())]
    def enum(i, n, pre, c):
        if i == len(h):
            print " ".join(map(str, pre))
            c[0] += 1
            if c[0] == 3:
                sys.exit()
            return
        # print 'i', i, 'n', n
        for p in permutations(s[n]):
            enum(i+len(s[n]), n+1, pre + list(p), c)
    enum(0, 0, [], [0])

if __name__ == '__main__':
    main()


import sys
import copy

def main():
    n = int(sys.stdin.readline())
    h = map(int, sys.stdin.readline().split())
    d = {}
    for j, i in enumerate(h):
        if i in d:
            d[i].append(j+1)
        else:
            d[i] = [j+1]
    if len(d) + 2 > n:
        print "NO"
        return

    c = 0
    s = sorted(d.items())
    for i, jj in s:
        for j in jj:
            print j,
    print

    n = 0
    for i, jj in s:
        if len(jj) > 1 and n == 0:
            for j in reversed(jj):
                print j,
            n += 1
        else:
            for j in jj:
                print j,
    print

    n = 0
    for i, jj in s:
        if len(jj) > 1:
            n += 1
        if n == 2:
            for j in reversed(jj):
                print j,
        else:
            for j in jj:
                print j,
    print

if __name__ == '__main__':
    main()


import sys
import copy
from itertools import permutations

def main():
    n = int(sys.stdin.readline())
    h = map(int, sys.stdin.readline().split())
    d = {}
    for j, i in enumerate(h):
        if i in d:
            d[i].append(j+1)
        else:
            d[i] = [j+1]
    if len(d) + 2 > n:
        print "NO"
        return
    print "YES"
    s = [item[1] for item in sorted(d.items())]
    def enum(i, n, pre, c):
        if i == len(h) or n == len(s):
            print " ".join(map(str, pre))
            c[0] += 1
            if c[0] == 3:
                sys.exit()
            return
        # print 'i', i, 'n', n
        for p in permutations(s[n]):
            enum(i+len(s[n]), n+1, pre + list(p), c)
    enum(0, 0, [], [0])

if __name__ == '__main__':
    main()


n = int(raw_input())
h = map(int, raw_input().split())[:n]
a = [(x, i+1) for i, x in enumerate(h)]
a = sorted(a, key=lambda x: x[0])
p = []
for i in range(1, len(a)):
  if a[i][0] == a[i-1][0]:
    p.append(i)
    if len(p) >= 2: break
if len(p) < 2: print 'NO'
else:
  print 'YES'
  def output(a):
    print ' '.join(map(str, [x[1] for x in a]))
  output(a)
  for pi in p:
    a[pi-1], a[pi] = a[pi], a[pi-1]
    output(a)


n = int(raw_input())
h = map(int, raw_input().split())[:n]
a = [(x, i+1) for i, x in enumerate(h)]
a = sorted(a, key=lambda x: x[0])
p = []
for i in range(1, len(a)):
  if a[i][0] == a[i-1][0]:
    p.append(i)
    if len(p) >= 2: break
if len(p) < 2: print 'NO'
else:
  def output(a):
    print ' '.join(map(str, [x[1] for x in a]))
  output(a)
  for pi in p:
    a[pi-1], a[pi] = a[pi], a[pi-1]
    output(a)


import fileinput, math, collections

###          ###
# utility func #
###          ###

dbug = True

def btos(b):
	return 'YES' if b else 'NO'

def pd(s, label=''):
	global dbug
	if dbug:
		header = 'debug:'
		if label != '':
			header += ' (%s)\t' % label
		print header, s

def stoi(s):
	return([ int(x) for x in s.split() ])

def perm(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
	return math.factorial(n) / math.factorial(k)

def comb(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
		assert(n - k > 0)
	return perm(n, k, False) / math.factorial(n - k)

def tol(actual, expected, tolerance=10 ** -9):
	if type(actual) != type([]):
		(actual, expected) = ([ actual ], [ expected ])
	if len(actual) != len(expected):
		return False
	r = [ expected[i] - tolerance <= actual[i] <= expected[i] + tolerance for i in xrange(len(actual)) ]
	return sum(r) == len(r)

def btod(b):
	return b * 2 - 1

def _sigma(f):
	return f * (f + 1) / 2

# sum(x from i to f)
def sigma(i, f, wheels=True):
	if wheels:
		assert(i >= 0)
		assert(f >= 0)
	return _sigma(f) - _sigma(i - 1)

def ps(l, wheels=True):
	if wheels:
		assert(len(l) > 0)
	r = [ l[0] ] * len(l)
	for i in xrange(1, len(l)):
		r[i] = l[i] + r[i - 1]
	return r

def test_utilities():
	assert(stoi('1 2 3\n') == [ 1, 2, 3 ])
	assert(stoi('') == stoi('\n') == [])
	assert(perm(10, 5) == 30240)
	assert(comb(10, 5) == 252)
	assert(tol(0.0, 0.0) == tol(0.0, 0.1, tolerance=0.1) == tol(0.0, 10, tolerance=10) == True)
	assert(tol(0.0, 0.1) == tol(0.0, 0.1, tolerance=0.1 - 10 ** -9) == False)
	assert(tol([ 1.0, 1.1 ], [ 2.0, 2.1 ], tolerance=1) == True)
	assert(tol([ 1, 2 ], [ 1 ]) == tol([ 1 ], [ 1, 2 ]) == False)
	assert(_sigma(1) == 1)
	assert(_sigma(10) == 55)
	assert(sigma(1, 10) == 55)
	assert(sigma(3, 10) == 52)
	assert(sigma(10, 10) == 10)
	assert(sigma(10, 11) == 21)
	assert(ps([ 1 ]) == [ 1 ])
	assert(ps([ 1, 2, 3, 4, 5 ]) == [ 1, 3, 6, 10, 15 ])
	assert(btod(0) == -1)
	assert(btod(1) == 1)
	assert(btos(True) == 'YES')
	assert(btos(False) == 'NO')

###          ###
# code follows #
###          ###

# args = [ 'line 1', 'line 2', ... ]
def proc_input(args):
	return(stoi(args[1]))

def solve(args, verbose=False):
	tasks = list(enumerate(proc_input(args)))
	tasks = [ (k + 1, v) for (k, v) in tasks ]
	tasks.sort(key=lambda(k, v): v)
	count = collections.defaultdict(list)
	for (k, v) in tasks:
		count[v].append(k)
	# perm stuff
	perm = []
	succ = False
	for v in count:
		if len(count[v]) >= 2:
			perm.append(v)
		if len(count[v]) > 2 or len(perm) == 2:
			succ = True
			break
	output = [ [], [], [] ]
	if succ:
		curr = 0
		for v in sorted(count.keys()):
			if v not in perm:
				for i in xrange(3):
					output[i] += count[v]
			else:
				tmp = collections.deque(count[v])
				for i in xrange(3):
					output[i] += tmp
					if not curr or (curr and i):
						tmp.rotate()
					# 2-element list -- move onto next perm
					if list(tmp) == count[v]:
						curr += 1
	if verbose:
		print btos(succ)
		if succ:
			for x in output:
				print ' '.join([ str(y) for y in x ])
	return(succ, output)

def test():
	solve([ '4', '1 3 3 1' ], verbose=True)
	solve([ '5', '2 4 1 4 8' ], verbose=True)

if __name__ == '__main__':
	from sys import argv
	if argv.pop() == 'test':
		test_utilities()
		test()
	else:
		dbug = False
		solve(list(fileinput.input()), verbose=True)


import fileinput, math, collections

###          ###
# utility func #
###          ###

dbug = True

def btos(b):
	return 'YES' if b else 'NO'

def pd(s, label=''):
	global dbug
	if dbug:
		header = 'debug:'
		if label != '':
			header += ' (%s)\t' % label
		print header, s

def stoi(s):
	return([ int(x) for x in s.split() ])

def perm(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
	return math.factorial(n) / math.factorial(k)

def comb(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
		assert(n - k > 0)
	return perm(n, k, False) / math.factorial(n - k)

def tol(actual, expected, tolerance=10 ** -9):
	if type(actual) != type([]):
		(actual, expected) = ([ actual ], [ expected ])
	if len(actual) != len(expected):
		return False
	r = [ expected[i] - tolerance <= actual[i] <= expected[i] + tolerance for i in xrange(len(actual)) ]
	return sum(r) == len(r)

def btod(b):
	return b * 2 - 1

def _sigma(f):
	return f * (f + 1) / 2

# sum(x from i to f)
def sigma(i, f, wheels=True):
	if wheels:
		assert(i >= 0)
		assert(f >= 0)
	return _sigma(f) - _sigma(i - 1)

def ps(l, wheels=True):
	if wheels:
		assert(len(l) > 0)
	r = [ l[0] ] * len(l)
	for i in xrange(1, len(l)):
		r[i] = l[i] + r[i - 1]
	return r

def test_utilities():
	assert(stoi('1 2 3\n') == [ 1, 2, 3 ])
	assert(stoi('') == stoi('\n') == [])
	assert(perm(10, 5) == 30240)
	assert(comb(10, 5) == 252)
	assert(tol(0.0, 0.0) == tol(0.0, 0.1, tolerance=0.1) == tol(0.0, 10, tolerance=10) == True)
	assert(tol(0.0, 0.1) == tol(0.0, 0.1, tolerance=0.1 - 10 ** -9) == False)
	assert(tol([ 1.0, 1.1 ], [ 2.0, 2.1 ], tolerance=1) == True)
	assert(tol([ 1, 2 ], [ 1 ]) == tol([ 1 ], [ 1, 2 ]) == False)
	assert(_sigma(1) == 1)
	assert(_sigma(10) == 55)
	assert(sigma(1, 10) == 55)
	assert(sigma(3, 10) == 52)
	assert(sigma(10, 10) == 10)
	assert(sigma(10, 11) == 21)
	assert(ps([ 1 ]) == [ 1 ])
	assert(ps([ 1, 2, 3, 4, 5 ]) == [ 1, 3, 6, 10, 15 ])
	assert(btod(0) == -1)
	assert(btod(1) == 1)
	assert(btos(True) == 'YES')
	assert(btos(False) == 'NO')

###          ###
# code follows #
###          ###

# args = [ 'line 1', 'line 2', ... ]
def proc_input(args):
	return(stoi(args[1]))

def solve(args, verbose=False):
	tasks = list(enumerate(proc_input(args)))
	tasks = [ (k + 1, v) for (k, v) in tasks ]
	tasks.sort(key=lambda(k, v): v)
	count = collections.defaultdict(list)
	for (k, v) in tasks:
		count[v].append(k)
	# perm stuff
	perm = []
	succ = False
	for v in count:
		if len(count) >= 2:
			perm.append(v)
		if len(count) > 2 or len(perm) == 2:
			succ = True
			break
	if succ:
		output = [ [], [], [] ]
		curr = 0
		for v in count:
			if v not in perm:
				for i in xrange(3):
					output[i] += count[v]
			else:
				tmp = collections.deque(count[v])
				for i in xrange(3):
					output[i] += tmp
					if curr and not i:
						tmp.rotate()
					# 2-element list -- move onto next perm
					if list(tmp) == count[v]:
						curr += 1
	if verbose:
		print btos(succ)
		if succ:
			for x in output:
				print ' '.join([ str(y) for y in x ])
	return(succ, output)

def test():
	solve([ '4', '1 3 3 1' ], verbose=True)

if __name__ == '__main__':
	from sys import argv
	if argv.pop() == 'test':
		test_utilities()
		test()
	else:
		dbug = False
		solve(list(fileinput.input()), verbose=True)


import fileinput, math, collections

###          ###
# utility func #
###          ###

dbug = True

def btos(b):
	return 'YES' if b else 'NO'

def pd(s, label=''):
	global dbug
	if dbug:
		header = 'debug:'
		if label != '':
			header += ' (%s)\t' % label
		print header, s

def stoi(s):
	return([ int(x) for x in s.split() ])

def perm(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
	return math.factorial(n) / math.factorial(k)

def comb(n, k, wheels=True):
	if wheels:
		assert(n > 0)
		assert(k > 0)
		assert(n - k > 0)
	return perm(n, k, False) / math.factorial(n - k)

def tol(actual, expected, tolerance=10 ** -9):
	if type(actual) != type([]):
		(actual, expected) = ([ actual ], [ expected ])
	if len(actual) != len(expected):
		return False
	r = [ expected[i] - tolerance <= actual[i] <= expected[i] + tolerance for i in xrange(len(actual)) ]
	return sum(r) == len(r)

def btod(b):
	return b * 2 - 1

def _sigma(f):
	return f * (f + 1) / 2

# sum(x from i to f)
def sigma(i, f, wheels=True):
	if wheels:
		assert(i >= 0)
		assert(f >= 0)
	return _sigma(f) - _sigma(i - 1)

def ps(l, wheels=True):
	if wheels:
		assert(len(l) > 0)
	r = [ l[0] ] * len(l)
	for i in xrange(1, len(l)):
		r[i] = l[i] + r[i - 1]
	return r

def test_utilities():
	assert(stoi('1 2 3\n') == [ 1, 2, 3 ])
	assert(stoi('') == stoi('\n') == [])
	assert(perm(10, 5) == 30240)
	assert(comb(10, 5) == 252)
	assert(tol(0.0, 0.0) == tol(0.0, 0.1, tolerance=0.1) == tol(0.0, 10, tolerance=10) == True)
	assert(tol(0.0, 0.1) == tol(0.0, 0.1, tolerance=0.1 - 10 ** -9) == False)
	assert(tol([ 1.0, 1.1 ], [ 2.0, 2.1 ], tolerance=1) == True)
	assert(tol([ 1, 2 ], [ 1 ]) == tol([ 1 ], [ 1, 2 ]) == False)
	assert(_sigma(1) == 1)
	assert(_sigma(10) == 55)
	assert(sigma(1, 10) == 55)
	assert(sigma(3, 10) == 52)
	assert(sigma(10, 10) == 10)
	assert(sigma(10, 11) == 21)
	assert(ps([ 1 ]) == [ 1 ])
	assert(ps([ 1, 2, 3, 4, 5 ]) == [ 1, 3, 6, 10, 15 ])
	assert(btod(0) == -1)
	assert(btod(1) == 1)
	assert(btos(True) == 'YES')
	assert(btos(False) == 'NO')

###          ###
# code follows #
###          ###

# args = [ 'line 1', 'line 2', ... ]
def proc_input(args):
	return(stoi(args[1]))

def solve(args, verbose=False):
	tasks = list(enumerate(proc_input(args)))
	tasks = [ (k + 1, v) for (k, v) in tasks ]
	tasks.sort(key=lambda(k, v): v)
	count = collections.defaultdict(list)
	for (k, v) in tasks:
		count[v].append(k)
	# perm stuff
	perm = []
	succ = False
	for v in count:
		if len(count) >= 2:
			perm.append(v)
		if len(count) > 2 or len(perm) == 2:
			succ = True
			break
	if succ:
		output = [ [], [], [] ]
		curr = 0
		for v in count:
			if v not in perm:
				for i in xrange(3):
					output[i] += count[v]
			else:
				tmp = collections.deque(count[v])
				for i in xrange(3):
					output[i] += tmp
					if not curr or (curr and i):
						tmp.rotate()
					# 2-element list -- move onto next perm
					if list(tmp) == count[v]:
						curr += 1
	if verbose:
		print btos(succ)
		if succ:
			for x in output:
				print ' '.join([ str(y) for y in x ])
	return(succ, output)

def test():
	solve([ '4', '1 3 3 1' ], verbose=True)

if __name__ == '__main__':
	from sys import argv
	if argv.pop() == 'test':
		test_utilities()
		test()
	else:
		dbug = False
		solve(list(fileinput.input()), verbose=True)


# your code goes here
import sys
class Difficulty:
    def __init__(self, pos, val):
        self.pos = pos
        self.val = val
    def __lt__(self,other):
        return self.val<other.val

n=int(raw_input())
a=map(int,sys.stdin.readline().split(" "))

b=[]

for i in range(0,n):
    b.append(Difficulty(i,a[i]))
b.sort()
num=0
for i in range(0,n-1):
    if(b[i].val==b[i+1].val):
        num+=1
    if(num>=2):
        break
if(num>=2):
    print "YES"
    print " ".join(str(x.pos+1) for x in b)
    for i in range(0,n-1):
        if(b[i].val==b[i+1].val):
            temp=b[i].pos
            b[i].pos=b[i+1].pos
            b[i+1].pos=temp
            print " ".join(str(x.pos+1) for x in b)
            temp=b[i].pos
            b[i].pos=b[i+1].pos
            b[i+1].pos=temp
            num-=1
        if(num<=0):
            break
else:
    print "NO"


n=int(raw_input())
d={}
for i, h in enumerate(map(int, raw_input().split())):
	difficulty,count,idx =d.get(h, (h,0,[]))
	d[h]=(h,count+1,idx+[i+1])

cnt=1
ans1=[]
ans2=[]
ans3=[]
for key in sorted(d):
	difficulty,count,idx =d[key]

	if count==2 and cnt==1:
		ans2+=[idx[1]]+[idx[0]]
		ans3+=[idx[0]]+[idx[1]]
		cnt=2
	elif count==2 and cnt==2:
		ans2+=[idx[0]]+[idx[1]]
		ans3+=[idx[1]]+[idx[0]]
		cnt=3
	elif count>2 and cnt<3:
		ans2+=[idx[0]] +[idx[2]]+[idx[1]] +[idx[3:]]
		ans3+=[idx[1]] +[idx[2]]+[idx[0]] + [idx[3:]]
		cnt=3
	else:
		ans2+=idx[:]
		ans3+=idx[:]
	ans1+=idx[:]

if cnt!=3:
	print "NO"
else:
	print "YES"
	for i in ans1:
		print i,
	print
	for i in ans2:
		print i,
	print
	for i in ans3:
		print i,


n=int(raw_input())
d={}
for i, h in enumerate(map(int, raw_input().split())):
	difficulty,count,idx =d.get(h, (h,0,[]))
	d[h]=(h,count+1,idx+[i+1])

cnt=1
ans1=[]
ans2=[]
ans3=[]
for key in sorted(d):
	difficulty,count,idx =d[key]

	if count==2 and cnt==1:
		ans2+=[idx[1]]+[idx[0]]
		ans3+=[idx[0]]+[idx[1]]
		cnt=2
	elif count==2 and cnt==2:
		ans2+=[idx[0]]+[idx[1]]
		ans3+=[idx[1]]+[idx[0]]
		cnt=3
	elif count>2 and cnt<3:
		ans2+=[idx[0]] +[idx[2]]+[idx[1]] +idx[3:]
		ans3+=[idx[1]] +[idx[2]]+[idx[0]] + idx[3:]
		cnt=3
	else:
		ans2+=idx[:]
		ans3+=idx[:]
	ans1+=idx[:]

if cnt!=3:
	print "NO"
else:
	print "YES"
	for i in ans1:
		print i,
	print
	for i in ans2:
		print i,
	print
	for i in ans3:
		print i,


import math

n = int(raw_input())
h = [int(x) for x in raw_input().split()]

total = 1
for a in set(h):
    total *= math.factorial(h.count(a))
if total<3:
    print 'NO'
    exit()

task = sorted((h[i],i) for i in xrange(n))

para = []
for i in xrange(n-1):
    if task[i][0]==task[i+1][0]:
        para.append(i)
print 'YES'
print ' '.join([str(x[1]+1) for x in task])

tmp = task[para[0]]
task[para[0]]=task[para[0]+1]
task[para[0]+1]=tmp

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

tmp = task[para[1]]
task[para[1]]=task[para[1]+1]
task[para[1]+1]=tmp

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


l=lambda:map(int, raw_input().split())
n=input()
h=l()
a=[(i,v) for i,v in enumerate(h,1)]
a.sort(key=lambda e:e[1])
r=[]
cnt=0
for i in xrange(1,n):
    if a[i][1] == a[i-1][1]:
        cnt+=2
        r.append((i-1,i))
        if cnt>=4:
            break
if cnt<3:
    print 'NO'
    exit()
ans=list(zip(*a)[0])
print "YES"
print ' '.join(map(str,ans))
for x,y in r:
    ans[x],ans[y] = ans[y],ans[x]
    print ' '.join(map(str,ans))


from collections import defaultdict, OrderedDict
from itertools import permutations

n = int(raw_input())
nums = map(int, raw_input().split())

d = defaultdict(list)
for i in xrange(0, n):
	d[nums[i]].append(i)

permCount = 1
for k in d:
	permCount *= len(d[k])

if permCount < 3:
	print "NO"
	exit(0)

print "YES"

orderedD = OrderedDict(sorted(d.items()))

results = [[], [], []]
nextR = 0

for k, v in orderedD.iteritems():
	if len(v) == 1:
		for i in range(0, 3):
			results[i].extend(v)
	else:
		perms = permutations(v)
		if len(v) == 2:
			results[nextR].extend(next(perms))
			results[(nextR + 1) % 3].extend(next(perms))
			results[(nextR + 2) % 3].extend(v)
			nextR = (nextR + 2) % 3
		else:
			results[0].extend(next(perms))
			results[1].extend(next(perms))
			results[2].extend(next(perms))

for r in results:
	for i in r:
		print i + 1,
	print


def printt(P):
    fir = P[0]
    sec = P[1]
    third = P[2]

    print "YES"

    for i in fir:
        print i,

    print "\n"

    for w in sec:
        print w,

    print "\n"

    for y in third:
        print y,

x = raw_input()

n = int(x)  #4

x = raw_input()

L = x.split() # ['1','3','3','1']
T = []

for i in range(n):
    T.append(int(L[i]))

T1 = list(set(T))
T1.sort()

#T.index(3) gives first appearance of 3 in T.

plans = [[], [], []]

changes = 0

for y in range(len(T1)):

    diff = T1[y]
    indices = [i for i, x in enumerate(T) if x == diff]

    woo = len(indices)
    if woo==1:
        plans[0] = plans[0]+[str(indices[0]+1)]
        plans[1] = plans[1]+[str(indices[0]+1)]
        plans[2] = plans[2]+[str(indices[0]+1)]

    elif woo==2:
        if changes==0:
            plans[0] = plans[0]+[str(indices[0]+1)]+[str(indices[1]+1)]
            plans[1] = plans[1]+[str(indices[1]+1)]+[str(indices[0]+1)]
            plans[2] = plans[2]+[str(indices[1]+1)]+[str(indices[0]+1)]
            changes += 1
        else:
            plans[0] = plans[0]+[str(indices[0]+1)]+[str(indices[1]+1)]
            plans[1] = plans[1]+[str(indices[0]+1)]+[str(indices[1]+1)]
            plans[2] = plans[2]+[str(indices[1]+1)]+[str(indices[0]+1)]
            changes += 1

    elif woo >= 3:

        plans[0] = plans[0]+[str(indices[0]+1)]+[str(indices[1]+1)]+[str(indices[2]+1)]
        plans[1] = plans[1]+[str(indices[1]+1)]+[str(indices[0]+1)]+[str(indices[2]+1)]
        plans[2] = plans[2]+[str(indices[2]+1)]+[str(indices[0]+1)]+[str(indices[1]+1)]
        changes += 2

        for i in range(3,woo):
            plans[0] = plans[0]+[str(indices[i]+1)]
            plans[1] = plans[1]+[str(indices[i]+1)]
            plans[2] = plans[2]+[str(indices[i]+1)]

if changes <= 1:
    print "NO"

else:
    printt(plans)


def printt(P):
    fir = P[0]
    sec = P[1]
    third = P[2]

    print "YES"

    for i in fir:
        print i,

    print "\n"

    for w in sec:
        print w,

    print "\n"

    for y in third:
        print y,

x = raw_input()

n = int(x)  #4

x = raw_input()

L = x.split() # ['1','3','3','1']
T = []

for i in range(n):
    T.append(int(L[i]))

T1 = list(set(T))
T1.sort()

#T.index(3) gives first appearance of 3 in T.

plans = [[], [], []]

changes = 0

for y in range(len(T1)):

    diff = T1[y]
    indices = [i for i, x in enumerate(T) if x == diff]

    woo = len(indices)
    if woo==1:
        plans[0] = plans[0]+[str(indices[0]+1)]
        plans[1] = plans[1]+[str(indices[0]+1)]
        plans[2] = plans[2]+[str(indices[0]+1)]

    elif woo==2:
        if changes==0:
            plans[0] = plans[0]+[str(indices[0]+1)]+[str(indices[1]+1)]
            plans[1] = plans[1]+[str(indices[1]+1)]+[str(indices[0]+1)]
            plans[2] = plans[2]+[str(indices[1]+1)]+[str(indices[0]+1)]
            changes += 1
        else:
            plans[0] = plans[0]+[str(indices[0]+1)]+[str(indices[1]+1)]
            plans[1] = plans[1]+[str(indices[0]+1)]+[str(indices[1]+1)]
            plans[2] = plans[2]+[str(indices[1]+1)]+[str(indices[0]+1)]
            changes += 1

    elif woo >= 3:

        plans[0] = plans[0]+[str(indices[0]+1)]+[str(indices[1]+1)]+[str(indices[2]+1)]
        plans[1] = plans[1]+[str(indices[1]+1)]+[str(indices[0]+1)]+[str(indices[2]+1)]
        plans[2] = plans[2]+[str(indices[2]+1)]+[str(indices[0]+1)]+[str(indices[1]+1)]
        changes += 1

        for i in range(3,woo):
            plans[0] = plans[0]+[str(indices[i]+1)]
            plans[1] = plans[1]+[str(indices[i]+1)]
            plans[2] = plans[2]+[str(indices[i]+1)]

if changes <= 1:
    print "NO"

else:
    printt(plans)


import itertools

N = int(raw_input())
h = map(int, raw_input().split())
m = [0] * 2000
ans = [[] for _ in xrange(3)]
count = 0
for t in xrange(2000):
    check = []
    for i, hh in enumerate(h):
        if hh == t:
            check.append(i + 1)
    if len(check) == 1 or count >= 2:
        for k in xrange(3):
            ans[k] += check
    elif len(check) >= 3:
        b = itertools.permutations(check, len(check))
        for k in xrange(3):
            ans[k] += [_ for _ in b.next()]
        count += 2
    elif len(check) == 2:
        ans[0] += check
        if count == 0:
            ans[1] += reversed(check)
        else:
            ans[1] += check
        ans[2] += reversed(check)
        count += 1
if count >= 2:
    print "YES"
    for k in xrange(3):
        print " ".join(map(str, ans[k]))
else:
    print "NO"


import itertools

N = int(raw_input())
h = map(int, raw_input().split())
m = [0] * 2000
ans = [[] for _ in xrange(3)]
count = 0
for t in xrange(1, 2001):
    check = []
    for i, hh in enumerate(h):
        if hh == t:
            check.append(i + 1)
    if len(check) == 1 or count >= 2:
        for k in xrange(3):
            ans[k] += check
    elif len(check) >= 3:
        b = itertools.permutations(check, len(check))
        for k in xrange(3):
            ans[k] += [_ for _ in b.next()]
        count += 2
    elif len(check) == 2:
        ans[0] += check
        if count == 0:
            ans[1] += reversed(check)
        else:
            ans[1] += check
        ans[2] += reversed(check)
        count += 1
if count >= 2:
    print "YES"
    for k in xrange(3):
        print " ".join(map(str, ans[k]))
else:
    print "NO"


import itertools

N = int(raw_input())
h = map(int, raw_input().split())
m = [0] * 2000
ans = [[] for _ in xrange(3)]
count = 0
for t in xrange(2000):
    check = []
    for i, hh in enumerate(h):
        if hh == t:
            check.append(i + 1)
    if len(check) == 1 or count >= 2:
        for k in xrange(3):
            ans[k] += check
    elif len(check) >= 3:
        for k in xrange(3):
            ans[k] += itertools.product(check, 2)
        count += 2
    elif len(check) == 2:
        ans[0] += check
        if count == 0:
            ans[1] += reversed(check)
        else:
            ans[1] += check
        ans[2] += reversed(check)
        count += 1
if count >= 2:
    print "YES"
    for k in xrange(3):
        print " ".join(map(str, ans[k]))
else:
    print "NO"


from collections import defaultdict

def main():
    n=input()

    l=map(int,raw_input().strip().split())
    d=defaultdict(list)

    for i,c in enumerate(l):
        d[c].append(i+1)

    ks=list(d.keys())
    ks.sort()

    index=0
    sol=[[],[],[]]

    for diff in ks:
        if len(d[diff])==1 or index>1:
            for i in range(3):
                sol[i].extend(d[diff])
        else:
            aux=d[diff]
            x=d[diff]
            n=len(x)
            for i in range(3):
                for j in range(n):
                    sol[(i+index)%3].append(x[(j+i-index)%n])

            index+=(len(x)-1)
    if index>1:
        print "YES"
        for i in range(3):print " ".join(map(str,sol[i]))
    else:print "NO"

main()


n = input()
a = map(int,raw_input().split())
b = [x for x in sorted(enumerate(a),key=lambda x:x[1])]
i = []
s = 0
for x in xrange(1,n):
    if b[x][1] == b[x-1][1]:
        s += 1
        i.append((x-1,x))
if s >= 2:
    c = list(zip(*b)[0])
    print "YES"
    print " ".join([str(x+1) for x in c])
    for x,y in i[:2]:
        c[x],c[y] = c[y],c[x]
        print " ".join([str(x+1) for x in c])
else:
    print "NO"


import operator
N=input()
a=map(int,raw_input().split(' '))
b={}
count={}
for i in xrange(N):
	try:
		b[a[i]].append(i)
		count[a[i]]+=1
	except KeyError:
		b[a[i]]=[i]
		count[a[i]]=1
a.sort()
Possible=1
#print a
#print b
#print count
Count= sorted(count.items(), key=operator.itemgetter(1),reverse=True)
for i in count:
	Possible*=count[i]
if(Possible<3):
	print "NO"
else:
	k=0
	l=0
	print "YES"
	Pos={}
	for i in a:
		Pos[i]=0
#	print Count[0][1]
	if(Count[0][1]==2):
		for i in xrange(N):
			print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			Pos[a[i]]+=1
		for i in a:
			if(Count[0][0]!=i):
				Pos[i]=0
			else:
			 	Pos[i]=1
		print
		for i in xrange(N):
		  	print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			Pos[a[i]]+=1
		for i in a:
		 	if(Count[1][0]!=i):
				 Pos[i]=0
			else:
				 Pos[i]=1
		print
		for i in xrange(N):
			 print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			 Pos[a[i]]+=1
	elif(Count[0][1]>=3):
		  for i in xrange(N):
#		  	  print "i = ",i
			  print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			  Pos[a[i]]+=1
		  for i in a:
			  if(Count[0][0]!=i):
				Pos[i]=0
			  else:
				Pos[i]=1
		  print
		  for i in xrange(N):
			  print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			  Pos[a[i]]+=1
		  for i in a:
			  if(Count[0][0]!=i):
				Pos[i]=0
			  else:
				Pos[i]=2
		  print
		  for i in xrange(N):
			  print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			  Pos[a[i]]+=1


import operator
N=input()
a=map(int,raw_input().split(' '))
b={}
count={}
for i in xrange(N):
	try:
		b[a[i]].append(i)
		count[a[i]]+=1
	except KeyError:
		b[a[i]]=[i]
		count[a[i]]=1
a.sort()
Possible=1
#print a
#print b
#print count
Count= sorted(count.items(), key=operator.itemgetter(1))
for i in count:
	Possible*=count[i]
if(Possible<3):
	print "NO"
else:
	k=0
	l=0
	print "YES"
	Pos={}
	for i in a:
		Pos[i]=0
	if(Count[0][1]==2):
		for i in a:
			print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			Pos[a[i]]+=1
		for i in a:
			if(Count[0][0]!=i):
				Pos[i]=0
			else:
			 	Pos[i]=1
		print
		for i in a:
		  	print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			Pos[a[i]]+=1
		for i in a:
		 	if(Count[1][0]!=i):
				 Pos[i]=0
			else:
				 Pos[i]=1
		print
		for i in a:
			 print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			 Pos[a[i]]+=1
	elif(Count[0][1]>=3):
		  for i in a:
			  print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			  Pos[a[i]]+=1
		  for i in a:
			  if(Count[0][0]!=i):
				Pos[i]=0
			  else:
				Pos[i]=1
		  print
		  for i in a:
			  print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			  Pos[a[i]]+=1
		  for i in a:
			  if(Count[0][0]!=i):
				Pos[i]=0
			  else:
				Pos[i]=2
		  print
		  for i in a:
			  print b[a[i]][Pos[a[i]]%len(b[a[i]])]+1,
			  Pos[a[i]]+=1


def printLista(l):
	for e in l:
		print e[1],
	print

n = int(raw_input())
lista = map(int, raw_input().split())
aux = []
for i in xrange(n):
	aux.append([lista[i],i+1])

cont = 0
for i in xrange(n):
	for j in xrange(i+1,n):
		if(aux[i][0] == aux[j][0]): cont += 1

if cont <= 1:
	print "NO"
else:
	print "YES"
	aux.sort()
	printLista(aux)
	listas_impressas = 1
	for i in xrange(n-1):
		if aux[i][0] == aux[i+1][0]:
			aux[i],aux[i+1] = aux[i+1],aux[i]
			printLista(aux)
			listas_impressas += 1
		if listas_impressas >= 3:
			break


n=input()
d=map(int,raw_input().split())
l2=[]
for i in range(n):
    l2.append([d[i],i+1])
l2.sort(key=lambda x:x[0])
ans=[]
dd=[]
for i in l2:
    dd.append(str(i[1]))
ans.append(dd)
fl=1
for i in range(n-1):
    if fl==3:break
    if l2[i][0]==l2[i+1][0]:
        l2[i+1][1],l2[i][1]=l2[i][1],l2[i+1][1]
        aux=[]
        for j in l2:
            aux.append(str(j[1]))
        ans.append(aux)
        fl+=1
if fl==3:
    print 'YES'
    print ' '.join(ans[0])
    print ' '.join(ans[1])
    print ' '.join(ans[2])

else :
    print 'NO'


n = int(raw_input())
v = map(int, raw_input().split())
e1=-1
e2=-1
d = {}

for x in v:
    if x not in d:
        d[x]=1
    else:
        d[x] +=1

def gl(l):
    i=1
    ll=[]
    for x in l:
        ll.append((x,i))
        i+=1
    return ll

def np(l):
    lll=l[1:]
    lll.append(l[0])
    return lll

def pl(l):
    for (x,y) in l:
        print y,
    print ''

z = sorted([(x, d[x]) for x in d.keys() if d[x]>=2], key=lambda x: -x[1])
if len(z)==0:
    print 'NO'
elif z[0][1]>=3:
    print 'YES'
    vv = gl(v)
    vv.sort()
    p=z[0][0]
    l1 = filter(lambda x: x[0]<p,vv)
    l2 = filter(lambda x: x[0]>p,vv)
    l3 = filter(lambda x: x[0]==p,vv)
    pl(vv)
    l3 = np(l3)
    pl(l1+l3+l2)
    l3 = np(l3)
    pl(l1+l3+l2)
elif len(z)>=2:
    print 'YES'
    vv = gl(v)
    vv.sort()
    p1=z[0][0]
    p2=z[1][0]
    if p1>p2:
        (p1,p2) = (p2,p1)
    #print vv
    l1 = filter(lambda x: x[0]<p1,vv)
    l2 = filter(lambda x: x[0]>p1 and x[0]<p2,vv)
    l3 = filter(lambda x: x[0]>p2,vv)
    lp1 = filter(lambda x: x[0]==p1,vv)
    lp2 = filter(lambda x: x[0]==p2,vv)
    pl(vv)
    lp1 = np(lp1)
    pl(l1+lp1+l2+lp2+l3)
    lp2 = np(lp2)
    pl(l1+lp1+l2+lp2+l3)
else:
    print 'NO'


n = int( input() )
l = map( int, raw_input().split() )
if len(l) - len( set(l) ) < 2:
    print 'NO'
else:
    print 'YES'
    def f( v ):
        for i in range( len(v) ):
            if v[i][0] == v[i+1][0] and v[i][1] < v[i+1][1]:
                v[i],v[i+1] = v[i+1],v[i]
                break
        print " ".join( [ str(y) for x,y in v ] )

    v = sorted( zip( l, range( 1, n+1 ) ) )

    print " ".join( [ str(y) for x,y in v ] )
    f( v )
    f( v )


n=input()
s=map(int,raw_input().split())
dic={i:[] for i in range(1,2001)}
c=0
for i in range(n):
    dic[s[i]].append(i+1)
    if len(dic[s[i]])>1:
        c+=1
if c<2:
    print 'NO'
else:
    print 'YES'
    for i in dic:
        for j in dic[i]:
            print j,
    print '\n'
    flag=False
    m1=0
    for i in dic:
        if len(dic[i])>2:
            flag=True
            m1=i
            break
    if not flag:
        d=0
        m=[]
        for i in dic:
            if len(dic[i])>1:
                d+=1
                m.append(i)
            if d==2:
                break
        for i in range(1,m[0]):
            for j in dic[i]:
                print j,
        print dic[m[0]][1],dic[m[0]][0],
        for i in range(m[0]+1,m[1]):
            for j in dic[i]:
                print j,
        print dic[m[1]][1],dic[m[1]][0],
        for j in dic[m[1]][2:]:
            print j,
        for i in range(m[1]+1,2001):
            for j in dic[i]:
                print j,
        print '\n'
        for i in range(1,m[0]):
            for j in dic[i]:
                print j,
        print dic[m[0]][1],dic[m[0]][0],
        for i in range(m[0]+1,2001):
            for j in dic[i]:
                print j,
        print '\n'
    else:
        for i in range(1,m1):
            for j in dic[i]:
                print j,
        print dic[m1][1],dic[m1][0],dic[m1][2]
        for i in dic[m1][3:]:
            print i,
        for i in range(m1+1,2001):
            for j in dic[i]:
                print j,
        print '\n'
        for i in range(1,m1):
            for j in dic[i]:
                print j,
        print dic[m1][1],dic[m1][2],dic[m1][0]
        for i in dic[m1][3:]:
            print i,
        for i in range(m1+1,2001):
            for j in dic[i]:
                print j,
        print '\n'


n=input()
s=map(int,raw_input().split())
dic={i:[] for i in range(1,2001)}
c=0
for i in range(n):
    dic[s[i]].append(i+1)
    if len(dic[s[i]])>1:
        c+=1
if c<2:
    print 'NO'
else:
    print 'YES'
    for i in dic:
        for j in dic[i]:
            print j,
    print '\n'
    flag=False
    m1=0
    for i in dic:
        if len(dic[i])>2:
            flag=True
            m1=i
            break
    if not flag:
        d=0
        m=[]
        for i in dic:
            if len(dic[i])>1:
                d+=1
                m.append(i)
            if d==2:
                break
        for i in range(1,m[0]):
            for j in dic[i]:
                print j,
        print dic[m[0]][1],dic[m[0]][0],
        for i in range(m[0]+1,m[1]):
            for j in dic[i]:
                print j,
        print dic[m[1]][1],dic[m[1]][0],
        for j in dic[m[1]][2:]:
            print j,
        for i in range(m[1]+1,2001):
            for j in dic[i]:
                print j,
        print '\n'
        for i in range(1,m[0]):
            for j in dic[i]:
                print j,
        print dic[m[0]][1],dic[m[0]][0],
        for i in range(m[0]+1,2001):
            for j in dic[i]:
                print j,
        print '\n'
    else:
        for i in range(1,m1):
            for j in dic[i]:
                print j,
        print dic[m1][1],dic[m1][0],dic[m1][2]
        for i in range(m1+1,2001):
            for j in dic[i]:
                print j,
        print '\n'
        for i in range(1,m1):
            for j in dic[i]:
                print j,
        print dic[m1][1],dic[m1][2],dic[m1][0]
        for i in range(m1+1,2001):
            for j in dic[i]:
                print j,
        print '\n'


n=input()
ll=map(int,raw_input().split())
c=1
l=[]
for i in ll:
	l.append([i,c])
	c+=1
dic={}
l=sorted(l)
for i in ll:
	dic[i]=True
if n<=2:
	print "NO"
else:
	if len(dic)>=n-1:
		print "NO"
	else:
		ans1=[]
		ans2=[]
		ans3=[]
		flag=0
		ch1=0
		ch2=0
		for i in xrange(n):
			ans1.append(l[i][1])
			if True:
				if flag<2:
					if l[i][0]==l[i+1][0]:
						if flag==0:
							ans2.append(l[i+1][1])
							ans2.append(l[i][1])
							flag=1
							ch1=2
						elif flag==1:
							ans3.append(l[i+1][1])
							ans3.append(l[i][1])
							flag=2
							ch2=2
			if ch1==0:
				ans2.append(l[i][1])
			if ch2==0:
				ans3.append(l[i][1])
			if ch1>0:
				ch1-=1
			if ch2>0:
				ch2-=1
		print "YES"
		for i in ans1:
			print i,
		print
		for i in ans2:
			print i,
		print
		for i in ans3:
			print i,
		print


n=input()
h=map(int,raw_input().split())
d={}
ma=0
hi=-1
num2=0
i=0
while(i<n):
	if h[i] not in d:
		d[h[i]]=[]
	d[h[i]].append(i+1)
	l=len(d[h[i]])
	if(l>ma):
		ma=l
		hi=h[i]
	if(l==2):
		num2=num2+1
	elif(l==3):
		num2=num2-1
	i=i+1
if(ma>2):
	k1=[]
	k2=d[hi][3:]
	a=d[hi][0:1]
	b=d[hi][1:2]
	c=d[hi][2:3]
	k3=[]
	i=1
	while(i<=2000):
		if i in d:
			if(i<hi):
				k1=k1+d[i]
			elif(i>hi):
				k3=k3+d[i]
		i=i+1
	print ' '.join(str(p) for p in k1+a+b+c+k2+k3)
	print ' '.join(str(p) for p in k1+a+c+b+k2+k3)
	print ' '.join(str(p) for p in k1+b+a+c+k2+k3)
elif(num2>=2):
	hi1=-1
	hi2=-1
	i=1
	while(i<=2000):
		if i in d:
			if len(d[i])==2 and hi1==-1:
				hi1=i
				a=[d[i][0]]
				b=[d[i][1]]
			elif len(d[i])==2:
				hi2=i
				e=[d[i][0]]
				f=[d[i][1]]
				break
		i=i+1
	k1=[]
	k2=[]
	k3=[]
	i=1
	while(i<=2000):
		if i in d:
			if(i<hi1):
				k1=k1+d[i]
			elif(i>hi2):
				k3=k3+d[i]
			elif(i>hi1 and i<hi2):
				k2=k2+d[i]
		i=i+1
	print ' '.join(str(p) for p in k1+a+b+k2+e+f+k3)
	print ' '.join(str(p) for p in k1+b+a+k2+e+f+k3)
	print ' '.join(str(p) for p in k1+b+a+k2+f+e+k3)
else:
	print "NO"


n=input()
h=map(int,raw_input().split())
d={}
ma=0
hi=-1
num2=0
i=0
while(i<n):
	if h[i] not in d:
		d[h[i]]=[]
	d[h[i]].append(i+1)
	l=len(d[h[i]])
	if(l>ma):
		ma=l
		hi=h[i]
	if(l==2):
		num2=num2+1
	elif(l==3):
		num2=num2-1
	i=i+1
if(ma>2):
	print "YES"
	k1=[]
	k2=d[hi][3:]
	a=d[hi][0:1]
	b=d[hi][1:2]
	c=d[hi][2:3]
	k3=[]
	i=1
	while(i<=2000):
		if i in d:
			if(i<hi):
				k1=k1+d[i]
			elif(i>hi):
				k3=k3+d[i]
		i=i+1
	print ' '.join(str(p) for p in k1+a+b+c+k2+k3)
	print ' '.join(str(p) for p in k1+a+c+b+k2+k3)
	print ' '.join(str(p) for p in k1+b+a+c+k2+k3)
elif(num2>=2):
	print "YES"
	hi1=-1
	hi2=-1
	i=1
	while(i<=2000):
		if i in d:
			if(len(d[i])==2 and hi1==-1):
				hi1=i
				a=[d[i][0]]
				b=[d[i][1]]
			elif(len(d[i])==2):
				hi2=i
				e=[d[i][0]]
				f=[d[i][1]]
				i=2001
				break
		i=i+1
	k1=[]
	k2=[]
	k3=[]
	i=1
	while(i<=2000):
		if i in d:
			if(i<hi1):
				k1=k1+d[i]
			elif(i>hi2):
				k3=k3+d[i]
			elif(i>hi1 and i<hi2):
				k2=k2+d[i]
		i=i+1
	print ' '.join(str(p) for p in k1+a+b+k2+e+f+k3)
	print ' '.join(str(p) for p in k1+b+a+k2+e+f+k3)
	print ' '.join(str(p) for p in k1+b+a+k2+f+e+k3)
else:
	print "NO"


n=input()
h=map(int,raw_input().split())
d={}
ma=0
hi=-1
num2=0
i=0
while(i<n):
	if h[i] not in d:
		d[h[i]]=[]
	d[h[i]].append(i+1)
	l=len(d[h[i]])
	if(l>ma):
		ma=l
		hi=h[i]
	if(l==2):
		num2=num2+1
	elif(l==3):
		num2=num2-1
	i=i+1
if(ma>2):
	k1=[]
	k2=d[hi][3:]
	a=d[hi][0:1]
	b=d[hi][1:2]
	c=d[hi][2:3]
	k3=[]
	i=1
	while(i<=2000):
		if i in d:
			if(i<hi):
				k1=k1+d[i]
			elif(i>hi):
				k3=k3+d[i]
		i=i+1
	print ' '.join(str(p) for p in k1+a+b+c+k2+k3)
	print ' '.join(str(p) for p in k1+a+c+b+k2+k3)
	print ' '.join(str(p) for p in k1+b+a+c+k2+k3)
elif(num2>=2 and ma==2):
	print "YES"
	hi1=-1
	hi2=-1
	i=1
	while(i<=2000):
		if i in d:
			if(len(d[i])==2 and hi1==-1):
				hi1=i
				a=[d[i][0]]
				b=[d[i][1]]
			elif(len(d[i])==2):
				hi2=i
				e=[d[i][0]]
				f=[d[i][1]]
				break
		i=i+1
	k1=[]
	k2=[]
	k3=[]
	i=1
	while(i<=2000):
		if i in d:
			if(i<hi1):
				k1=k1+d[i]
			elif(i>hi2):
				k3=k3+d[i]
			elif(i>hi1 and i<hi2):
				k2=k2+d[i]
		i=i+1
	print ' '.join(str(p) for p in k1+a+b+k2+e+f+k3)
	print ' '.join(str(p) for p in k1+b+a+k2+e+f+k3)
	print ' '.join(str(p) for p in k1+b+a+k2+f+e+k3)
else:
	print "NO"


#!/usr/bin/env python

def read():
    n = input()
    idxValList = list(enumerate(map(int, raw_input().split())))
    return (n, idxValList)

def work((n, idxValList)):
    idxValList.sort(key=lambda x: x[1])

    ans = []
    for i in range(3):
        toPush = range(n)
        cnt = 0
        for j in range(n - 1):
            if cnt < i and idxValList[j][1] == idxValList[j + 1][1]:
                toPush[j], toPush[j + 1] = toPush[j + 1], toPush[j]
                cnt += 1

        if cnt < i:
            print "NO"
            return

        ans.append([idxValList[toPush[j]][0] + 1 for j in range(n)])

    print "YES"
    for i in range(3):
        print " ".join(map(str,ans[i]))

if __name__ == "__main__":
    work(read())


#include<stdio.h>
#include<stdlib.h>
#define FOR(i, t, n) for (i=t; i<n; i++)

struct task{
  int i, h;
} t[2000];

int compare(const void *a, const void *b){
  return (*((struct task *) a)).h - (*((struct task *) b)).h;
  // return ((struct task *) a)->h - ((struct task *) b)->h;
}

int swap(int a, int b, int c){
  if (a == b) return c;
  if (a == c) return b;
  return a;
}

int main(){
  int n, i, cnt, j;
  static struct pairs{
    int a, b;
  } pp[2000];
  scanf("%d", &n);
  FOR(i, 0, n){
    scanf("%d", &t[i].h);
    t[i].i = i + 1;
  }
  qsort(t, n, sizeof(*t), compare);
  cnt = 0;
  FOR(i, 1, n)
    if (t[i - 1].h == t[i].h){
      pp[cnt].a = t[i - 1].i;
      pp[cnt].b = t[i].i;
      cnt++;
    }
  if (cnt < 2) printf("NO\n");
  else{
    printf("YES\n");
    FOR(i, 0, n) printf("%d ", t[i].i);
    printf("\n");
    FOR(i, 0, 2){
      FOR(j, 0, n) printf("%d ", swap(t[j].i, pp[i].a, pp[i].b));
      printf("\n");
    }
  }
  return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define N 2000

int hh[N], x;

int compare1(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = hh[i] - hh[j];
	int diff2 = i - j;

	return diff1 != 0 ? diff1 : diff2;
}

int compare2(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = hh[i] - hh[j];
	int diff2 = x % 2 == 0 ? j - i : i - j;
	x++;

	return diff1 != 0 ? diff1 : diff2;
}

int compare3(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = hh[i] - hh[j];
	int diff2 = j - i;

	return diff1 != 0 ? diff1 : diff2;
}

int same(int n, int *aa, int *bb) {
	int i;

	for (i = 0; i < n; i++)
		if (aa[i] != bb[i])
			return 0;
	return 1;
}

int main() {
	static int ii1[N], ii2[N], ii3[N];
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &hh[i]);
		ii1[i] = i;
		ii2[i] = i;
		ii3[i] = i;
	}
	qsort(ii1, n, sizeof *ii1, compare1);
	x = 0;
	qsort(ii2, n, sizeof *ii2, compare2);
	qsort(ii3, n, sizeof *ii3, compare3);
	if (same(n, ii1, ii2) || same(n, ii1, ii3) || same(n, ii2, ii3)) {
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	for (i = 0; i < n; i++)
		printf("%d ", ii1[i] + 1);
	printf("\n");
	for (i = 0; i < n; i++)
		printf("%d ", ii2[i] + 1);
	printf("\n");
	for (i = 0; i < n; i++)
		printf("%d ", ii3[i] + 1);
	printf("\n");
	return 0;
}


/* Coached by rainboy */
#include <stdio.h>
#include <stdlib.h>

#define N 2000

int hh[N];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return hh[i] - hh[j];
}

int main() {
	static int ii[N];
	int n, i, j, i1, i2, tmp;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &hh[i]);
		ii[i] = i;
	}
	qsort(ii, n, sizeof *ii, compare);
	for (i = 2; i < n; i++)
		if (hh[ii[i - 2]] == hh[ii[i - 1]] && hh[ii[i - 1]] == hh[ii[i]]) {
			printf("YES\n");
			for (j = 0; j < n; j++)
				printf("%d ", ii[j] + 1);
			printf("\n");
			tmp = ii[i];
			ii[i] = ii[i - 1];
			ii[i - 1] = tmp;
			for (j = 0; j < n; j++)
				printf("%d ", ii[j] + 1);
			printf("\n");
			tmp = ii[i - 1];
			ii[i - 1] = ii[i - 2];
			ii[i - 2] = tmp;
			for (j = 0; j < n; j++)
				printf("%d ", ii[j] + 1);
			printf("\n");
			return 0;
		}
	for (i1 = 1; i1 < n; i1++)
		for (i2 = i1 + 2; i2 < n; i2++)
			if (hh[ii[i1 - 1]] == hh[ii[i1]] && hh[ii[i2 - 1]] == hh[ii[i2]]) {
				printf("YES\n");
				for (j = 0; j < n; j++)
					printf("%d ", ii[j] + 1);
				printf("\n");
				tmp = ii[i1];
				ii[i1] = ii[i1 - 1];
				ii[i1 - 1] = tmp;
				for (j = 0; j < n; j++)
					printf("%d ", ii[j] + 1);
				printf("\n");
				tmp = ii[i2];
				ii[i2] = ii[i2 - 1];
				ii[i2 - 1] = tmp;
				for (j = 0; j < n; j++)
					printf("%d ", ii[j] + 1);
				printf("\n");
				return 0;
			}
	printf("NO\n");
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define N 2000

int hh[N];

int compare1(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = hh[i] - hh[j];
	int diff2 = i - j;

	return diff1 != 0 ? diff1 : diff2;
}

int x = 0;

int compare2(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = hh[i] - hh[j];
	int diff2 = x % 2 == 0 ? j - i : i - j;
	x++;

	return diff1 != 0 ? diff1 : diff2;
}

int compare3(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = hh[i] - hh[j];
	int diff2 = j - i;

	return diff1 != 0 ? diff1 : diff2;
}

int same(int n, int *aa, int *bb) {
	int i;

	for (i = 0; i < n; i++)
		if (aa[i] != bb[i])
			return 0;
	return 1;
}

int main() {
	static int ii1[N], ii2[N], ii3[N];
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &hh[i]);
		ii1[i] = i;
		ii2[i] = i;
		ii3[i] = i;
	}
	qsort(ii1, n, sizeof *ii1, compare1);
	qsort(ii2, n, sizeof *ii2, compare2);
	qsort(ii3, n, sizeof *ii3, compare3);
	if (same(n, ii1, ii2) || same(n, ii1, ii3) || same(n, ii2, ii3)) {
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	for (i = 0; i < n; i++)
		printf("%d ", ii1[i] + 1);
	printf("\n");
	for (i = 0; i < n; i++)
		printf("%d ", ii2[i] + 1);
	printf("\n");
	for (i = 0; i < n; i++)
		printf("%d ", ii3[i] + 1);
	printf("\n");
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define N 2000

int hh[N];

int compare1(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = hh[i] - hh[j];
	int diff2 = i - j;

	return diff1 != 0 ? diff1 : diff2;
}

int compare2(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = hh[i] - hh[j];
	int diff2 = j - i;

	return diff1 != 0 ? diff1 : diff2;
}

int x = 0;

int compare3(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = hh[i] - hh[j];
	int diff2 = x == 0 ? j - i : i - j;

	x = 1 - x;
	return diff1 != 0 ? diff1 : diff2;
}

int same(int n, int *aa, int *bb) {
	int i;

	for (i = 0; i < n; i++)
		if (aa[i] != bb[i])
			return 0;
	return 1;
}

int main() {
	static int ii1[N], ii2[N], ii3[N];
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &hh[i]);
		ii1[i] = i;
		ii2[i] = i;
		ii3[i] = i;
	}
	qsort(ii1, n, sizeof *ii1, compare1);
	qsort(ii2, n, sizeof *ii2, compare2);
	qsort(ii3, n, sizeof *ii3, compare3);
	if (same(n, ii1, ii2) || same(n, ii1, ii3) || same(n, ii2, ii3)) {
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	for (i = 0; i < n; i++)
		printf("%d ", ii1[i] + 1);
	printf("\n");
	for (i = 0; i < n; i++)
		printf("%d ", ii2[i] + 1);
	printf("\n");
	for (i = 0; i < n; i++)
		printf("%d ", ii3[i] + 1);
	printf("\n");
	return 0;
}