/*--------------------------
|  Author- Advitiya Brijesh |
|  PIE @ MNNIT Allahabad    |
|  advitiyabrijesh@gmail.com|
|                           |
---------------------------*/
#include<bits/stdc++.h>
using namespace std;
//		std macros
typedef long long ll;
typedef vector<list<ll> > vli;
typedef vector<ll > vi;
typedef vector<pair<ll,ll> > vpll;
typedef vector<pair<int,int> > vpii;
typedef pair<int ,int> pii;
//		dereference
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define in insert
#define pu push
#define fr front
//  	loops
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<b;++i)
#define PER(i,b) for(int i=b;i>=0;--i)
#define all(X) (X).begin(), (X).end()
//  	I/O
#define dsd(X) int (X); scanf("%d", &X)
#define dsd2(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define dsd3(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define sd(n) scanf("%d",&n)
#define sld(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define oll(n) printf("%lld\n",n)
//		set values
#define mset(n,k) memset(n,k,sizeof(n))
#define MOD 1000000007
#define MAX 12345678
//		main fn
map<pii,int>m;
int main()
{
	int x[2],y[2];
	rep(i,2){
		sd(x[i]),sd(y[i]);
	}
	int n;
	sd(n);
	int r[n],a[n],b[n];
	rep(i,n){
		sd(r[i]),sd(a[i]),sd(b[i]);
		for(int j=a[i];j<=b[i];++j){
			m[mp(r[i],j)]=-1;
		}
		//it=m.find(r[i]);
		//cout<<"ri "<<r[i]<<" a "<<(*it).S.F<<" b "<<(*it).S.S<<endl;
	}
	queue<pii >q;
	q.push(mp(x[0],y[0]));
	m[mp(x[0],y[0])]=0;
	map<pii,int >::iterator it;
	while(!q.empty()){
		pii nve=q.front();
		q.pop();
		//lev[nve]=1;
		//if(it!=m.end()){
			/*if(nve.S+1<=(*it).S.S && nve.S+1>=(*it).S.F && lev.find(mp(nve.F,nve.S+1))==lev.end()){
				q.push(mp(nve.F,nve.S+1));
				//lev[mp(nve.F,nve.S+1)]=1;
				lev[mp(nve.F,nve.S+1)]=lev[nve]+1;
			}*/
			pii temp=mp(nve.F,nve.S+1);
			if(m[temp]==-1 && m.count(temp)){
				m[temp]=m[nve]+1;
				q.push(temp);
			}
			temp=mp(nve.F,nve.S-1);
			if(m[temp]==-1 && m.count(temp)){
				m[temp]=m[nve]+1;
				q.push(temp);
			}
			temp=mp(nve.F+1,nve.S-1);
			if(m[temp]==-1 && m.count(temp)){
				m[temp]=m[nve]+1;
				q.push(temp);
			}
			temp=mp(nve.F+1,nve.S);
			if(m[temp]==-1 && m.count(temp)){
				m[temp]=m[nve]+1;
				q.push(temp);
			}
			temp=mp(nve.F+1,nve.S+1);
			if(m[temp]==-1 && m.count(temp)){
				m[temp]=m[nve]+1;
				q.push(temp);
			}
			temp=mp(nve.F-1,nve.S-1);
			if(m[temp]==-1 && m.count(temp)){
				m[temp]=m[nve]+1;
				q.push(temp);
			}
			temp=mp(nve.F-1,nve.S+1);
			if(m[temp]==-1 && m.count(temp)){
				m[temp]=m[nve]+1;
				q.push(temp);
			}
			temp=mp(nve.F-1,nve.S);
			if(m[temp]==-1 && m.count(temp)){
				m[temp]=m[nve]+1;
				q.push(temp);
			}
			/*if(nve.S-1<=(*it).S.S && nve.S-1>=(*it).S.F && lev.find(mp(nve.F,nve.S-1))==lev.end()){
				q.push(mp(nve.F,nve.S-1));
				//lev[mp(nve.F,nve.S-1)]=1;
				lev[mp(nve.F,nve.S-1)]=lev[nve]+1;
			}
		//}
		it=m.find(nve.F.F+1);
		if(it!=m.end()){
			if(nve.S<=(*it).S.S && nve.S>=(*it).S.F && lev.find(mp(nve.F+1,nve.S))==lev.end()){
				q.push(mp(nve.F+1,nve.S));
				//lev[mp(nve.F+1,nve.S)]=1;
				lev[mp(nve.F+1,nve.S)]=lev[nve]+1;
			}
			if(nve.S+1<=(*it).S.S && nve.S+1>=(*it).S.F && lev.find(mp(nve.F+1,nve.S+1))==lev.end()){
				q.push(mp(nve.F+1,nve.S+1));
				//lev[mp(nve.F+1,nve.S+1)]=1;
				lev[mp(nve.F+1,nve.S+1)]=lev[nve]+1;
			}
			if(nve.S-1<=(*it).S.S && nve.S-1>=(*it).S.F && lev.find(mp(nve.F+1,nve.S-1))==lev.end()){
				q.push(mp(nve.F+1,nve.S-1));
				//lev[mp(nve.F+1,nve.S-1)]=1;
				lev[mp(nve.F+1,nve.S-1)]=lev[nve]+1;
			}
		}
		it=m.find(nve.F-1);
		if(it!=m.end()){
			if(nve.S<=(*it).S.S && nve.S>=(*it).S.F && lev.find(mp(nve.F-1,nve.S))==lev.end()){
				q.push(mp(nve.F-1,nve.S));
				//lev[mp(nve.F-1,nve.S)]=1;
				lev[mp(nve.F-1,nve.S)]=lev[nve]+1;
			}
			if(nve.S+1<=(*it).S.S && nve.S+1>=(*it).S.F && lev.find(mp(nve.F-1,nve.S+1))==lev.end()){
				q.push(mp(nve.F-1,nve.S+1));
				//lev[mp(nve.F-1,nve.S+1)]=1;
				lev[mp(nve.F-1,nve.S+1)]=lev[nve]+1;
			}
			if(nve.S-1<=(*it).S.S && nve.S-1>=(*it).S.F && lev.find(mp(nve.F-1,nve.S-1))==lev.end()){
				q.push(mp(nve.F-1,nve.S-1));
				//lev[mp(nve.F-1,nve.S-1)]=1;
				lev[mp(nve.F-1,nve.S-1)]=lev[nve]+1;
			}
		}*/
	}
	cout<<m[mp(x[1],y[1])];
	return 0;
}


/*--------------------------
|  Author- Advitiya Brijesh |
|  PIE @ MNNIT Allahabad    |
|  advitiyabrijesh@gmail.com|
|                           |
---------------------------*/
#include<bits/stdc++.h>
using namespace std;
//		std macros
typedef long long ll;
typedef vector<list<ll> > vli;
typedef vector<ll > vi;
typedef vector<pair<ll,ll> > vpll;
typedef vector<pair<int,int> > vpii;
typedef pair<int ,int> pii;
//		dereference
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define in insert
#define pu push
#define fr front
//  	loops
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<b;++i)
#define PER(i,b) for(int i=b;i>=0;--i)
#define all(X) (X).begin(), (X).end()
//  	I/O
#define dsd(X) int (X); scanf("%d", &X)
#define dsd2(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define dsd3(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define sd(n) scanf("%d",&n)
#define sld(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define oll(n) printf("%lld\n",n)
//		set values
#define mset(n,k) memset(n,k,sizeof(n))
#define MOD 1000000007
#define MAX 12345678
//		main fn
map<int,pii >m;
int main()
{
	int x[2],y[2];
	rep(i,2){
		sd(x[i]),sd(y[i]);
	}
	int n;
	sd(n);
	map<int,pii >::iterator it;
	int r[n],a[n],b[n];
	rep(i,n){
		sd(r[i]),sd(a[i]),sd(b[i]);
		it=m.find(r[i]);
		if(it==m.end()){
            m[r[i]]=mp(a[i],b[i]);
		}
		else{
            m[r[i]]=mp(min((*it).S.F,a[i]),max((*it).S.S,b[i]));
		}
		//it=m.find(r[i]);
		//cout<<"ri "<<r[i]<<" a "<<(*it).S.F<<" b "<<(*it).S.S<<endl;
	}
	map<pii,int> lev;
	queue<pii >q;
	q.push(mp(x[0],y[0]));
	lev[mp(x[0],y[0])]=0;
	while(!q.empty()){
		pii nve=q.front();
		q.pop();
		//lev[nve]=1;
		it=m.find(nve.F);
		if(it!=m.end()){
			if(nve.S+1<=(*it).S.S && nve.S+1>=(*it).S.F && !lev[mp(nve.F,nve.S+1)]){
				q.push(mp(nve.F,nve.S+1));
				//lev[mp(nve.F,nve.S+1)]=1;
				lev[mp(nve.F,nve.S+1)]=lev[nve]+1;
			}
			if(nve.S-1<=(*it).S.S && nve.S-1>=(*it).S.F && !lev[mp(nve.F,nve.S-1)]){
				q.push(mp(nve.F,nve.S-1));
				//lev[mp(nve.F,nve.S-1)]=1;
				lev[mp(nve.F,nve.S-1)]=lev[nve]+1;
			}
		}
		it=m.find(nve.F+1);
		if(it!=m.end()){
			if(nve.S<=(*it).S.S && nve.S>=(*it).S.F && !lev[mp(nve.F+1,nve.S)]){
				q.push(mp(nve.F+1,nve.S));
				//lev[mp(nve.F+1,nve.S)]=1;
				lev[mp(nve.F+1,nve.S)]=lev[nve]+1;
			}
			if(nve.S+1<=(*it).S.S && nve.S+1>=(*it).S.F && !lev[mp(nve.F+1,nve.S+1)]){
				q.push(mp(nve.F+1,nve.S+1));
				//lev[mp(nve.F+1,nve.S+1)]=1;
				lev[mp(nve.F+1,nve.S+1)]=lev[nve]+1;
			}
			if(nve.S-1<=(*it).S.S && nve.S-1>=(*it).S.F && !lev[mp(nve.F+1,nve.S-1)]){
				q.push(mp(nve.F+1,nve.S-1));
				//lev[mp(nve.F+1,nve.S-1)]=1;
				lev[mp(nve.F+1,nve.S-1)]=lev[nve]+1;
			}
		}
		it=m.find(nve.F-1);
		if(it!=m.end()){
			if(nve.S<=(*it).S.S && nve.S>=(*it).S.F && !lev[mp(nve.F-1,nve.S)]){
				q.push(mp(nve.F-1,nve.S));
				//lev[mp(nve.F-1,nve.S)]=1;
				lev[mp(nve.F-1,nve.S)]=lev[nve]+1;
			}
			if(nve.S+1<=(*it).S.S && nve.S+1>=(*it).S.F && !lev[mp(nve.F-1,nve.S+1)]){
				q.push(mp(nve.F-1,nve.S+1));
				//lev[mp(nve.F-1,nve.S+1)]=1;
				lev[mp(nve.F-1,nve.S+1)]=lev[nve]+1;
			}
			if(nve.S-1<=(*it).S.S && nve.S-1>=(*it).S.F && !lev[mp(nve.F-1,nve.S-1)]){
				q.push(mp(nve.F-1,nve.S-1));
				//lev[mp(nve.F-1,nve.S-1)]=1;
				lev[mp(nve.F-1,nve.S-1)]=lev[nve]+1;
			}
		}
	}
	if(lev[mp(x[1],y[1])])
	cout<<lev[mp(x[1],y[1])];
	else
        cout<<-1;
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <cassert>
using namespace std;

#define MII map<int, int>
#define MIMII map<int, MII>
#define PII pair<int, int>

MIMII m;

bool exists(int x, int y){
    MIMII::iterator i = m.find(x);
    return i != m.end() && i->second.count(y);
}

#define INF 100000000

int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int r, a, b;
        cin >> r >> a >> b;
        for(int j = a; j <= b; j++)
            m[r][j] = INF;
    }
    assert(exists(x0, y0) && exists(x1, y1));
    m[x0][y0] = 0;
    //m[x1][y1] = INF;

    queue<PII > q;
    q.push(make_pair(x0, y0));
    while(!q.empty()){
        PII p = q.front();
        int val = m[x][y];
        int x = p.first, y = p.second;
        q.pop();
        for(int i = x - 1; i <= x + 1; i++){
            for(int j = y - 1; j <= y + 1; j++){
                if(exists(i, j) && m[i][j] > val + 1){
                    m[i][j] = val + 1;
                    q.push(make_pair(i, j));
                }
            }
        }
    }

    cout << (m[x1][y1] != INF ? m[x1][y1] : -1) << endl;

}


#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <cassert>
using namespace std;

#define MII map<int, int>
#define MIMII map<int, MII>
#define PII pair<int, int>

MIMII m;

bool exists(int x, int y){
    MIMII::iterator i = m.find(x);
    return i != m.end() && i->second.count(y);
}

#define INF 100000000

int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int r, a, b;
        cin >> r >> a >> b;
        for(int j = a; j <= b; j++)
            m[r][j] = INF;
    }
    assert(exists(x0, y0) && exists(x1, y1));
    m[x0][y0] = 0;
    //m[x1][y1] = INF;

    queue<PII > q;
    q.push(make_pair(x0, y0));
    while(!q.empty()){
        PII p = q.back();
        int x = p.first, y = p.second;
        int val = m[x][y];
        q.pop();
        for(int i = x - 1; i <= x + 1; i++){
            for(int j = y - 1; j <= y + 1; j++){
                if(exists(i, j) && m[i][j] > val + 1){
                    m[i][j] = val + 1;
                    q.push(make_pair(i, j));
                }
            }
        }
    }

    cout << (m[x1][y1] != INF ? m[x1][y1] : -1) << endl;

}


#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <cassert>
using namespace std;

#define MII map<int, int>
#define MIMII map<int, MII>
#define PII pair<int, int>

MIMII m;

bool exists(int x, int y){
    MIMII::iterator i = m.find(x);
    return i != m.end() && i->second.count(y);
}

#define INF 100000000

int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int r, a, b;
        cin >> r >> a >> b;
        for(int j = a; j <= b; j++)
            m[r][j] = INF;
    }
    assert(exists(x0, y0) && exists(x1, y1));
    m[x0][y0] = 0;
    //m[x1][y1] = INF;

    queue<PII > q;
    q.push(make_pair(x0, y0));
    while(!q.empty()){
        PII p = q.front();
        int x = p.first, y = p.second;
        int val = m[x][y];
        q.pop();
        for(int i = x - 1; i <= x + 1; i++){
            for(int j = y - 1; j <= y + 1; j++){
                if(exists(i, j) && m[i][j] > val + 1){
                    m[i][j] = val + 1;
                    q.push(make_pair(i, j));
                }
            }
        }
    }

    cout << (m[x1][y1] != INF ? m[x1][y1] : -1) << endl;

}


#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
using namespace std;

#define MII map<int, int>
#define MIMII map<int, MII>
#define PII pair<int, int>

MIMII m;

bool exists(int x, int y){
    MIMII::iterator i = m.find(x);
    bool b = i != m.end(), c = i->second.count(y);
    return b && c;
}

#define INF 100000000

int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int r, a, b;
        cin >> r >> a >> b;
        for(int j = a; j <= b; j++)
            m[r][j] = INF;
    }
    m[x0][y0] = 0;
    m[x1][y1] = INF;

    queue<PII > q;
    q.push(make_pair(x0, y0));
    while(!q.empty()){
        PII p = q.back();
        int x = p.first, y = p.second;
        int val = m[x][y];
        q.pop();
        for(int i = x - 1; i <= x + 1; i++){
            for(int j = y - 1; j <= y + 1; j++){
                if(exists(i, j) && m[i][j] > val){
                    m[i][j] = val + 1;
                    q.push(make_pair(i, j));
                }
            }
        }
    }

    cout << (m[x1][y1] != INF ? m[x1][y1] : -1) << endl;

}


#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <cassert>
using namespace std;

#define MII map<int, int>
#define MIMII map<int, MII>
#define PII pair<int, int>

MIMII m;

bool exists(int x, int y){
    MIMII::iterator i = m.find(x);
    bool b = i != m.end(), c = i->second.count(y);
    return b && c;
}

#define INF 100000000

int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int r, a, b;
        cin >> r >> a >> b;
        for(int j = a; j <= b; j++)
            m[r][j] = INF;
    }
    assert(exists(x0, y0) && exists(x1, y1));
    m[x0][y0] = 0;
    //m[x1][y1] = INF;

    queue<PII > q;
    q.push(make_pair(x0, y0));
    while(!q.empty()){
        PII p = q.back();
        int x = p.first, y = p.second;
        int val = m[x][y];
        q.pop();
        for(int i = x - 1; i <= x + 1; i++){
            for(int j = y - 1; j <= y + 1; j++){
                if(exists(i, j) && m[i][j] > val + 1){
                    m[i][j] = val + 1;
                    q.push(make_pair(i, j));
                }
            }
        }
    }

    cout << (m[x1][y1] != INF ? m[x1][y1] : -1) << endl;

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
using namespace std;

struct vertT
{
    int r, c;
};

bool operator < (vertT v1, vertT v2)
{
    if (v1.r != v2.r)
        return v1.r < v2.r;
    else
        return v1.c < v2.c;
}

set<vertT> allowed;
map<vertT, int> dist;

void bfs (int rs, int cs)
{
    stack<vertT> verts;
    vertT v;
    v.r = rs;
    v.c = cs;
    verts.push(v);
    dist[v] = 0;

    int dx[] = {-1, 0, 1};

    while (!verts.empty())
    {
        v = verts.top();
        verts.pop();
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (i != 1 || j != 1)
                {
                    vertT w;
                    w.r = v.r + dx[i];
                    w.c = v.c + dx[j];
                    if (allowed.find(w) != allowed.end())
                    {
                        verts.push(w);
                        dist[w] = dist[v] + 1;
                        allowed.erase(w);
                    }
                }
            }
        }
    }
}

int main (void)
{
    int rs, cs, re, ce;
    cin >> rs >> cs >> re >> ce;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int r, a, b;
        cin >> r >> a >> b;

        for (int j = a; j <= b; j++)
        {
            vertT v;
            v.r = r;
            v.c = j;
            allowed.insert(v);
        }
    }

    bfs(rs, cs);
    vertT v;
    v.r = re;
    v.c = ce;
    if (dist[v] > 0)
        cout << dist[v] << endl;
    else
        cout << -1 << endl;
}


import random
lst=[]
t = int(input())
for i in range(t):
    n=int(input())
    lst.append(n)
for j in lst:
    if j%4==0:
        print('Yes')
        print([random.randrange(0,10**9,2)]+random.randint(1,10**9,2))
    else:
        print('No')


import random
lst=[]
t = int(input())
for i in range(t):
    n=int(input())
    lst.append(n)
for j in lst:
    if j%4==0:
        lst2=[]
        lst1 = [random.randrange(0,100,2) for k in range(n//2)]
        for m in range(len(lst1)):
            lst2.append(lst1[m] + ((-1)**m))
        print('Yes')
        print(lst1+lst2)
    else:
        print('No')


lst=[]
t = int(input())
for i in range(t):
    n=int(input())
    lst.append(n)
for j in lst:
    if j%4==0:
        lst2=[]
        lst1 = [k for k in range(2,j+1,2)]
        for m in range(len(lst1)-1):
            lst2.append(lst1[m]-1)
        lst2.append(lst1[-1]+len(lst1)-1)
        print('YES')
        for f in lst1+lst2:
            print(f,end=" ")
        print()
    else:
        print('NO')


lst=[]
t = int(input())
for i in range(t):
    n=int(input())
    lst.append(n)
for j in lst:
    lst2=[]
    lst1 = [k for k in range(2,j+1,2)]
    for m in range(len(lst1)-1):
        lst2.append(lst1[m]-1)
    lst2.append(lst1[-1]+len(lst1)-1)
    if lst2[-1]%2==0:
        print('No')
    else:
        print('Yes')
        print(lst1+lst2)


import random
lst=[]
t = int(input())
for i in range(t):
    n=int(input())
    lst.append(n)
for j in lst:
    if j%4==0:
        lst2=[]
        lst1 = [random.randrange(0,100,2) for k in range(n//2)]
        for m in range(len(lst1)-1):
            lst2.append(lst1[m]-1)
        lst2.append(lst1[-1]+len(lst1)-1)
        print('Yes')
        print(lst1+lst2)
    else:
        print('No')


lst=[]
t = int(input())
for i in range(t):
    n=int(input())
    lst.append(n)
for j in lst:
    if j%4==0:
        lst2=[]
        lst1 = [k for k in range(2,j+1,2)]
        for m in range(len(lst1)-1):
            lst2.append(lst1[m]-1)
        lst2.append(lst1[-1]+len(lst1)-1)
        print('Yes')
        print(lst1+lst2)
    else:
        print('No')


import math
t= int(input())
for i in range(t):
    n = int(input())
    print("YES" if n%4 == 0 else "NO")
    if (n%4 ==0):
        for j in range(1,n//2+1,3):
            print(2*j-1,2*(j+2)-1,end = ' ')
        for j in range(1,n//2+1,3):
            print(2*j, 2*(j+1),end=' ')
        print()


import math
t= int(input())
for i in range(t):
    n = int(input())
    print("YES" if n%4 == 0 else "NO")
    if (n%4 ==0):
        j = 1
        for k in range(1,n//4+1,1):
            print(2*j, 2*(j+1), end=' ')
            j+=3
        j = 1
        for k in range(1,n//4+1,1):
            print(2*j-1,2*(j+2)-1,end = ' ')
            j+=3
        print()


import math
t= int(input())
for i in range(t):
    n = int(input())
    print("YES" if n%4 == 0 else "NO")
    if (n%4 ==0):
        for j in range(1,n//2+1,3):
            print(2*j, 2*(j+1),end=' ')
        for j in range(1,n//2+1,3):
            print(2*j-1,2*(j+2)-1,end = ' ')
        print()


t=int(input())
a=[2*i for i in range(1,200000)]
b=[2*i+1 for i in range(200000)]
#print(a,b)
for i in range(t):
        p=int(input())
        if (p/2)%2==1:
                print("NO")
        else:
                ansl=a[:int(p/2)]
                ansr=b[:int(p/2)]
                ansr[-1]+=int(p/2)
                                #print(max(ansl),max(ansr))
                print("YES")
                print(" ".join(map(str,ansl+ansr)))


t=int(input())
a=[2*i for i in range(1,100000)]
b=[2*i+1 for i in range(100000)]
#print(a,b)
for i in range(t):
        p=int(input())
        if (p/2)%2==1:
                print("NO")
        else:
                ansl=a[:int(p/2)]
                ansr=b[:int(p/2)]
                ansr[-1]+=int(p/2)
                                #print(max(ansl),max(ansr))
                print("YES")
                print(" ".join(map(str,ansl+ansr)))


t=int(input())
a=[2*i for i in range(1,100000)]
b=[2*i+1 for i in range(100000)]
#print(a,b)
for i in range(t):
        p=int(input())
        if (p/2)%2==1:
                print("NO")
        else:
                ansl=[]
                ansr=[]
                countl,countr=0,0
                for j in range(len(a)):
                        if (j+1)%3!=0:
                                ansl.append(a[j])
                                countl+=1
                        if countl==int(p/2):
                                break
                for k in range(len(b)):
                        if (k+2)%3!=0:
                                ansr.append(b[k])
                                countr+=1
                        if countr==int(p/2):
                                break
                #print(max(ansl),max(ansr))
                print("YES")
                print(" ".join(map(str,ansl+ansr)))


t=int(input())
for i in range(0,t):
    n=int(input())
    arr1=[]
    arr2=[]
    if n%4 != 0:
        print('NO')
    else:
        for j in range(1,n+1):
            if j%2==0:
                arr1.append(j)
            else:
                arr2.append(j)
        arr2[-1]=arr2[-1]+int(n/2)
        for k in arr1:
            print(k,end=' ')
        for l in arr2:
            print(l,end=' ')


t=int(input())
for i in range(0,t):
    n=int(input())
    arr1=[]
    arr2=[]
    if n%4 != 0:
        print('NO')
    else:
        for j in range(1,n+1):
            if j%2==0:
                arr1.append(j)
            else:
                arr2.append(j)
        arr2[-1]=arr2[-1]+int(n/2)
        for k in arr1:
            print(k,end=' ')
        for l in arr2:
            print(l,end=' ')
        print()


t=int(input())
for i in range(0,t):
    n=int(input())
    arr1=[]
    arr2=[]
    if n%4 != 0:
        print('NO')
    else:
        print('YES')
        for j in range(1,n+1):
            if j%2==0:
                arr1.append(j)
            else:
                arr2.append(j)
        arr2[-1]=arr2[-1]+int(n/2)
        for k in arr1:
            print(k,end=' ')
        for l in arr2:
            print(l,end=' ')
        print()


for i in range (int(input())):

    n  = int(input())
    oddchk = n // 2
    # print("oddchk", oddchk)
    arr = []
    for i in range (1, n + 1):
        if i % 2 == 0:
            arr.append(i)
    # print(arr)
    # print("sum of arr", sum(arr))
    s = sum(arr)
    odd = []
    for i in range (n):
        if i % 2 != 0:
            odd.append(i)
            if sum(odd) > s:
                break
    if sum (arr) != sum (odd):
        odd.pop(-1)

    sumodd = sum (odd)
    if n == 2 or oddchk % 2 != 0:
        print("NO")
    else:
        p = n//2
        o = n - 1
        p = p + o
        odd.append(p)

        print("YES")
        ans = arr + odd
        print(*ans)


for i in range (int(input())):

    n  = int(input())
    arr = []
    for i in range (1, n + 1):
        if i % 2 == 0:
            arr.append(i)
    # print(arr)
    # print("sum of arr", sum(arr))
    s = sum(arr)
    odd = []
    for i in range (n):
        if i % 2 != 0:
            odd.append(i)
            if sum(odd) > s:
                break
    if sum (arr) != sum (odd):
        odd.pop(-1)

    sumodd = sum (odd)
    if n == 2:
        pass
    else:
        for i in range (odd[-1], s + 1, 2):
            if sumodd + i == s:
                odd.append(i)
                break

    if sum (arr) == sum (odd):
        print("YES")
        ans = arr + odd
        print(*ans)
    else:
        print("NO")


for i in range (int(input())):

    n  = int(input())
    oddchk = n // 2
    # print("oddchk", oddchk)
    arr = []
    for i in range (1, n + 1):
        if i % 2 == 0:
            arr.append(i)
    # print(arr)
    # print("sum of arr", sum(arr))
    s = sum(arr)
    odd = []
    for i in range (n):
        if i % 2 != 0:
            odd.append(i)
            if sum(odd) > s:
                break
    if sum (arr) != sum (odd):
        odd.pop(-1)

    sumodd = sum (odd)
    if n == 2 or oddchk % 2 != 0:
        pass
    else:
        p = n//2
        # print(p)
        o = n - 1
        # print(o)
        p = p + o
        odd.append(p)

        # for i in range (odd[-1], s + 1, 2):
        #     if sumodd + i == s:
        #         odd.append(i)
        #         break

    if sum (arr) == sum (odd):
        print("YES")
        ans = arr + odd
        print(*ans)
    else:
        print("NO")


for i in range (int(input())):

    n  = int(input())
    oddchk = n // 2
    # print("oddchk", oddchk)
    arr = []
    for i in range (1, n + 1):
        if i % 2 == 0:
            arr.append(i)
    # print(arr)
    # print("sum of arr", sum(arr))
    s = sum(arr)
    odd = []
    for i in range (n):
        if i % 2 != 0:
            odd.append(i)

    sumodd = sum (odd)
    if n == 2 or oddchk % 2 != 0:
        print("NO")
    else:
        p = n//2
        o = n - 1
        p = p + o
        odd.append(p)

        print("YES")
        ans = arr + odd
        print(*ans)


for i in range (int(input())):

    n  = int(input())
    oddchk = n // 2
    # print("oddchk", oddchk)
    arr = []
    for i in range (1, n + 1):
        if i % 2 == 0:
            arr.append(i)
    # print(arr)
    # print("sum of arr", sum(arr))
    s = sum(arr)
    odd = []
    for i in range (n):
        if i % 2 != 0:
            odd.append(i)
    odd.pop(-1)

    sumodd = sum (odd)
    if n == 2 or oddchk % 2 != 0:
        print("NO")
    else:
        p = n//2
        o = n - 1
        p = p + o
        odd.append(p)

        print("YES")
        ans = arr + odd
        print(*ans)


for i in range (int(input())):

    n  = int(input())
    oddchk = n % 2
    arr = []
    for i in range (1, n + 1):
        if i % 2 == 0:
            arr.append(i)
    # print(arr)
    # print("sum of arr", sum(arr))
    s = sum(arr)
    odd = []
    for i in range (n):
        if i % 2 != 0:
            odd.append(i)
            if sum(odd) > s:
                break
    if sum (arr) != sum (odd):
        odd.pop(-1)

    sumodd = sum (odd)
    if n == 2 or oddchk % 2 != 0:
        pass
    else:
        for i in range (odd[-1], s + 1, 2):
            if sumodd + i == s:
                odd.append(i)
                break

    if sum (arr) == sum (odd):
        print("YES")
        ans = arr + odd
        print(*ans)
    else:
        print("NO")


for i in range (int(input())):

    n  = int(input())
    arr = []
    for i in range (1, n + 1):
        if i % 2 == 0:
            arr.append(i)
    # print(arr)
    # print("sum of arr", sum(arr))
    s = sum(arr)
    odd = []
    for i in range (n):
        if i % 2 != 0:
            odd.append(i)
            if sum(odd) > s:
                break
    if sum (arr) != sum (odd):
        odd.pop(-1)

    if n == 2:
        pass
    else:
        for i in range (odd[-1], s + 1, 2):
            if sum (odd) + i == s:
                odd.append(i)
                break

    if sum (arr) == sum (odd):
        print("YES")
        ans = arr + odd
        print(*ans)
    else:
        print("NO")


for i in range (int(input())):
   #no

    n  = int(input())
    oddchk = n // 2
    # print("oddchk", oddchk)
    arr = []
    for i in range (1, n + 1):
        if i % 2 == 0:
            arr.append(i)
    # print(arr)
    # print("sum of arr", sum(arr))
    s = sum(arr)
    odd = []
    for i in range (n):
        if i % 2 != 0:
            odd.append(i)

    sumodd = sum (odd)
    if n == 2 or oddchk % 2 != 0:
        print("NO")
    else:
        p = n//2
        o = n - 1
        p = p + o
        odd.append(p)

        print("YES")
        ans = arr + odd
        print(*ans)


for _ in range(int(input())):
    n=int(input())
    if (n//2)%2==0:
        s1=""
        s2=""
        k,count=0,0
        for i in range(1,n//2):
            s2=s2+str(2*i-1)+" "
            s1=s1+str(2*i)+" "
            k+=2*i
            count+=2*i-1
        s=s1+str(n)+" "+s2+str(k+n-count)
        print("YES")
        print(s)
    else:
        print("NO")


for _ in range(int(input())):
    n=int(input())
    if (n//2)%2==0:
        s1=""
        s2=""
        k,count=0,0
        for i in range(1,n//2):
            s2=s2+str(2*i-1)+" "
            s1=s1+str(2*i)+" "
            k+=2*i
            count+=2*i-1
        s=s1+str(n)+" "+s2+str(k-count)
        print("YES")
        print(s)
    else:
        print("NO")


for _ in range(int(input())):
    n=int(input())
    if (n//2)%2==0:
        s=""
        k,count=0,0
        for i in range(1,n//2+1):
            s=s+str(2*i)+" "
            k+=2*i
        for i in range(1,n//2):
            s=s+str(2*i-1)+" "
            count+=2*i-1
        s=s+str(k-count)+" "
        print("YES")
        print(s)
    else:
        print("NO")


for _ in range(int(input())):
    n=int(input())
    if n%4==0:
        s=str(n)
        for i in range(n-2,1,-2):
            s=str(i)+" "+s+" "+str(i-1)
        print("YES")
        print(s+" "+str((3*n//2)-1))
    else:
        print("NO")


for _ in range(int(input())):
    n=int(input())
    if n%4==0:
        print("YES")
        for i in range(2,n+1,2):
            print(i,end=" ")
        for i in range(n-3,0,-2):
            print(i,end=" ")
        print(3*n//2-1)
    else:
        print("NO")


from sys import stdin, stdout
for _ in range(int(input())):
    n=int(stdin.readline())
    if n%4==0:
        s=str(n)
        for i in range(n-2,1,-2):
            s=str(i)+" "+s+" "+str(i-1)
        stdout.write("YES"+'\n')
        stdout.write(s+" "+str((3*n//2)-1)+'\n')
    else:
        stdout.write("NO"+'\n')


from math import log2
t = int(input())

for _ in range(t):
	n = int(input())
	half = n // 2
	if half & 1:
		print('NO')
		continue
	even = []
	odd  = []
	for i in range(1, half+1):
		even.append(2*i)
	for i in range(1, n-1, 2):
		odd.append(i)
	odd.append(sum(even) - sum(odd))

	print(*even, sep = ' ', end= ' ')
	print(*odd, sep =' ')


from math import log2
t = int(input())

for _ in range(t):
	n = int(input())
	half = n // 2
	if half & 1:
		print('NO')
		continue
	even = []
	odd  = []
	for i in range(1, half+1):
		even.append(2*i)
	for i in range(1, n-1, 2):
		odd.append(i)
	odd.append(sum(even) - sum(odd))

	print(*(even+odd), sep = ' ',end='\n')


from math import log2
t = int(input())

for _ in range(t):
	n = int(input())
	half = n // 2
	if half & 1:
		print('NO')
		continue
	even = []
	odd  = []
	for i in range(1, half+1):
		even.append(2*i)
	for i in range(1, n-1, 2):
		odd.append(i)
	odd.append(sum(even) - sum(odd))

	print(*(even+odd), sep = ' ')


from math import log2
t = int(input())

for _ in range(t):
	n = int(input())
	half = n // 2
	if half & 1:
		print('NO')
		continue
	even = []
	odd  = []
	for i in range(1, half+1):
		even.append(2*i)
	for i in range(1, n-1, 2):
		odd.append(i)
	odd.append(sum(even) - sum(odd))
	print('YES')
	print(*(even+odd), sep = ' ',end='\n')


t = int(input())

for i in range(t):
    n = int(input())
    if n%4 != 0:
        print('NO')
    else:
        print('YES')

        for i in range(2,n+1,2):
            print(i, end=" ")

        for i in range(1,n-2,2):
            print(i, end=" ")

        print(i + 2 + int(n/2))


t = int(input())

for i in range(t):
    k = ''
    n = int(input())
    if n%4 != 0:
        print('NO')
    else:
        print('YES')

        for i in range(2,n+1,2):
            if i == n/2:
                k += ' 0'
            else:
                k += ' ' + str(i)

        for i in range(1,n,2):
            k += ' ' + str(i)

        print(k[1:])


t = int(input())

for i in range(t):
    k = ''
    n = int(input())
    if n%4 != 0:
        print('NO')
    else:
        print('YES')

        for i in range(2,n+1,2):
            k += ' ' + str(i)

        for i in range(1,n-2,2):
            k += ' ' + str(int(i))

        k+= ' ' + str(i + 2 + int(n/2))

        print(k[1:])


l=[0 for i in range(10**5)]
sol=[]
s=6
j=0
for i in range((10**5)//2):
    while l[j]!=0:
        j+=1
    l[j]=1
    if s-(2*j+1)<10**5:
        l[s//2-(j+1)]=1
    sol.append(2*j+1)
    sol.append(s-(2*j+1))
    s+=8

t=int(input())
for i in range(t):
    n=int(input())
    if (n//2)%2!=0:
        print("NO")
    else:
        print("YES")
        for i in range(1,n//2+1):
            print(2*i,end=' ')
        for i in range(n//2):
            print(sol[i],end=' ')


l=[0 for i in range(10**5)]
sol=[]
s=6
j=0
for i in range((10**5)//2):
    while l[j]!=0:
        j+=1
    l[j]=1
    sol.append(2*j+1)
    sol.append(s-(2*j+1))
    s+=8

t=int(input())
for i in range(t):
    n=int(input())
    if (n//2)%2!=0:
        print("NO")
    else:
        print("YES")
        for i in range(1,n//2+1):
            print(2*i,end=' ')
        for i in range(n//2):
            print(sol[i],end=' ')


l=[0 for i in range(2*(10**5))]
sol=[]
s=6
j=0
for i in range((10**5)//2):
    while l[j]!=0:
        j+=1
    l[j]=1
    if s-(2*j+1)<2*(10**5):
        l[s//2-(j+1)]=1
    sol.append(2*j+1)
    sol.append(s-(2*j+1))
    s+=8

t=int(input())
for i in range(t):
    n=int(input())
    if (n//2)%2!=0:
        print("NO")
    else:
        print("YES")
        for i in range(1,n//2+1):
            print(2*i,end=' ')
        for i in range(n//2):
            print(sol[i],end=' ')


import math
for _ in range(int(input())):
    n=int(input())
    ans=[]
    if (n//2)%2==1:
        print("NO")
    else:
        odd=[]
        even=[]
        for i in range(n//2):
            x=n-i-1
            y=n+i+1
            if x%2==0:
                even.append(x)
            else:
                odd.append(x)
            if y%2==0:
                even.append(y)
            else:
                odd.append(y)
        for i in odd:
            even.append(i)
        print("YES")
        print(*even)


import math
for _ in range(int(input())):
    n=int(input())
    ans=[]
    if (n//2)%2==1:
        print("NO")
    else:
        odd=[]
        even=[]
        for i in range(n//2):
            x=n-i-1
            y=n+i+1
            if x%2==0:
                even.append(x)
            else:
                odd.append(x)
            if y%2==0:
                even.append(y)
            else:
                odd.append(y)
        print(*even,*odd)


import math
for _ in range(int(input())):
    n=int(input())
    ans=[]
    if (n//2)%2==1:
        print("NO")
    else:
        odd=[]
        even=[]
        for i in range(n//2):
            x=n-i-1
            y=n+i+1
            if x%2==0:
                even.append(x)
            else:
                odd.append(x)
            if y%2==0:
                even.append(y)
            else:
                odd.append(y)
        for i in odd:
            even.append(i)
        print(*even)


for i in range(int(input())):

    a=int(input())

    o=a//2
    e=a//2

    if o%2!=0:
        print('NO')
    elif o%2==0:
        if o==1:
            print('NO')
        else:
            o=[]
            e=[]
            x=0

            for k in range(a//2):
                if k<a//2-1:
                    if k==0:
                        o.append(1)
                        e.append(2)
                    else:
                        o.append(o[-1]+2)
                        e.append(e[-1]+2)
                else:

                    O=sum(o)
                    E=sum(e)

                    for j in range(o[-1]+2,1000000,2):
                        if (O+j)-E not in e:
                            o.append(j)
                            e.append((O+j)-E)
                            x+=1
                            break

            if x==1:
                print('YES')
                print(*(e+o))
            else:
                print('NO')


for i in range(int(input())):

    a=int(input())

    o=a//2
    e=a//2

    if o%2!=0:
        print('NO')
    elif o%2==0:
        if o==1:
            print('NO')
        else:
            o=[]
            e=[]
            x=0

            for k in range(a//2):
                if k<a//2-1:
                    if k==0:
                        o.append(1)
                        e.append(2)
                    else:
                        o.append(o[-1]+2)
                        e.append(e[-1]+2)
                else:

                    O=sum(o)
                    E=sum(e)

                    for  j in range(O+1,1000000):
                        if j%2==0 and j>E :
                            if j-E not in e:
                                o.append(j-O)
                                e.append(j-E)
                                x+=1
                                break

            if x==1:
                print('YES')
                print(*(e+o))
            else:
                print('NO')


for i in range(int(input())):

    a=int(input())

    o=a//2
    e=a//2

    if o%2!=0:
        print('NO')
    elif o%2==0:
        if o==1:
            print('NO')
        else:
            o=[]
            e=[]
            x=0

            for k in range(a//2):
                if k<a//2-1:
                    if k==0:
                        o.append(1)
                        e.append(2)
                    else:
                        o.append(o[-1]+2)
                        e.append(e[-1]+2)

            e.append(e[-1]+2)
            o.append(sum(e)-sum(o))

            print('YES')
            print(*(o+e))


for i in range(int(input())):

    a=int(input())

    if a//2==1:
        print('NO')
    else:
        o=[]
        e=[]
        x=0

        for k in range(a//2):
            if k<a//2-1:
                if k==0:
                    o.append(3)
                    e.append(2)
                else:
                    o.append(o[-1]+2)
                    e.append(e[-1]+2)
            else:
                e.append(e[-1]+6)
                for k in range(o[-1],1000000,2):
                    if sum(o)+k == sum(e):
                        o.append(k)
                        break

        if sum(o)==sum(e):
            print('YES')
            print(*(e+o))
        else:
            print('NO')


for i in range(int(input())):

    a=int(input())

    if a//2==1:
        print('NO')
    else:
        o=[]
        e=[]
        x=0

        for k in range(a//2):
            if k<a//2-1:
                if k==0:
                    o.append(1)
                    e.append(2)
                else:
                    o.append(o[-1]+2)
                    e.append(e[-1]+2)
            else:

                O=sum(o)
                E=sum(e)

                for w in range(max(O,E),1000000):
                    if (w-E)%2==0 and (w-O)%2!=0:
                        if w-E not in e:
                            if w-O not in o:
                                e.append(w-E)
                                o.append(w-O)
                                x+=1
                                break
        if x==1:
            print('YES')
            print(*(e+o))
        else:
            print('NO')


for i in range(int(input())):

    a=int(input())

    o=a//2
    e=a//2

    if o%2!=0:
        print('NO')
    elif o%2==0:
        if o==1:
            print('NO')
        else:
            o=[]
            e=[]
            x=0

            for k in range(a//2):
                if k<a//2-1:
                    if k==0:
                        o.append(1)
                        e.append(2)
                    else:
                        o.append(o[-1]+2)
                        e.append(e[-1]+2)

            e.append(e[-1]+2)
            o.append(sum(e)-sum(o))
            print('YES')
            print(*(o+e))


for i in range(int(input())):

    a=int(input())

    o=a//2
    e=a//2

    if o%2!=0:
        print('NO')
    elif o%2==0:
        if o==1:
            print('NO')
        else:
            o=[]
            e=[]
            x=0

            for k in range(a//2):
                if k<a//2-1:
                    if k==0:
                        o.append(1)
                        e.append(2)
                    else:
                        o.append(o[-1]+2)
                        e.append(e[-1]+2)

            e.append(e[-1]+2)
            o.append(sum(e)-sum(o))
            print('YES')
            print(*(e+o))


for i in range(int(input())):

    a=int(input())

    o=a//2
    e=a//2

    if o%2!=0:
        print('NO')
    elif o%2==0:
        if o==1:
            print('NO')
        else:
            o=[]
            e=[]
            x=0

            for k in range(a//2):
                if k<a//2-1:
                    if k==0:
                        o.append(1)
                        e.append(2)
                    else:
                        o.append(o[-1]+2)
                        e.append(e[-1]+2)
                else:

                    O=sum(o)
                    E=sum(e)

                    for  j in range(O,1000000):
                        if j%2==0 and j>E :
                            if j-E not in e:
                                o.append(j-O)
                                e.append(j-E)
                                x+=1
                                break

            if x==1:
                print('YES')
                print(*(e+o))
            else:
                print('NO')


for i in range(int(input())):

    a=int(input())

    o=a//2
    e=a//2

    if o%2!=0:
        print('NO')
    elif o%2==0:
        if o==1:
            print('NO')
        else:
            o=[]
            e=[]
            x=0

            for k in range(a//2):
                if k<a//2-1:
                    if k==0:
                        o.append(1)
                        e.append(2)
                    else:
                        o.append(o[-1]+2)
                        e.append(e[-1]+2)
                else:

                    O=sum(o)
                    E=sum(e)

                    for w in range(max(O,E),1000000):
                        if (w-E)%2==0 and (w-O)%2!=0:
                            if w-E not in e:
                                if w-O not in o:
                                    e.append(w-E)
                                    o.append(w-O)
                                    x+=1
                                    break
            if x==1:
                print('YES')
                print(*(e+o))
            else:
                print('NO')


tc=int(input())
for i in range(tc):
    n=int(input())
    if (n//2)%2==0:
        print('YES')
    else:
        print('NO')


from collections import deque
tc=int(input())
for i in range(tc):
    n=int(input())
    if (n//2)%2==0:
        print('YES')
        l=deque()
        for i in range(n//2):
            l.append((i+1)*2)
        for i in range(n//2):
            l.append(l[i]-1)
        l[-1]=l[(n//2)-1]+((n//2)-1)
        print(" ".join([str(x) for x in l]))
    else:
        print('NO')


tc=int(input())
for i in tc:
    n=int(input())
    if (n//2)%2==0:
        print('YES')
    else:
        print('NO')


t=int(input())
for i in range(t):
    n=int(input())
    if(n%4!=0):
        print('NO')
    else:
        a=[]
        b=[]
        for i in range(2,n+1,2):
            a.append(i)
        for t in range(1,n+1,2):
            b.append(t)
        b[-1]+=n//2
        print('YES\n')
        print(*a,*b)


t=int(input())
for i in range(t):
    n=int(input())
    if(n%4!=0):
        print('NO')
    else:
        a=[]
        b=[]
        for i in range(2,n+1,2):
            a.append(i)
        for t in range(1,n+1,2):
            b.append(t)
        b[-1]+=n//2
    print(*a,*b)


t=int(input())
for i in range(t):
    n=int(input())
    if(n%4!=0):
        print('NO')
    else:
        a=[]
        b=[]
        for i in range(2,n+1,2):
            a.append(i)
        for t in range(1,n+1,2):
            b.append(t)
        b[-1]+=n//2
        print(*a,*b)


t = int(input())
for i in range(t):
    n = int(input())
    l = []
    if n==2:
        print('NO')
    else:
        for i in range(1,n+1):
            l.append(i)
    l1 = l[1:n:2]
    l2 = l[0:n:2]

    if sum(l1) > sum(l2):
        while sum(l1) > sum(l2):
            l2.append(l2.pop() + 2)
            if sum(l1) == sum(l2):
                print('YES')
                print(*(l1+l2))
                break

        else:
            print('NO')


t = int(input())
for i in range(t):
    a = 2
    b = 1
    n = int(input())
    if (n/2)%2 != 0:
        print('NO')
    else:
        print("YES")
        for j in range(0,(n//2)):
            print(a,end=" ")
            a+=2
        val = a-2
        for k in range(0,(n//2)-1):
            print(b,end=" ")
            b+=2
        print(int(val+n/2-1))


t = int(input())
for i in range(t):
    a = 2
    b = 1
    n = int(input())
    if (n/2)%2 != 0:
        print('NO')
    else:
        print("YES")
        for j in range(0,(n//2)):
            print(a,end=" ")
            a+=2
        val = a-2
        for k in range(0,(n//2)-1):
            print(b,end=" ")
            b+=1
        print(int(val+n/2-1))


t = int(input())
for i in range(t):
    a = 2
    b = 1
    n = int(input())
    if n//2 == 1:
        print('NO')
    else:
        print("YES")
        for j in range(0,(n//2)):
            print(a,end=" ")
            a+=2
        val = a-2
        for k in range(0,(n//2)-1):
            print(b,end=" ")
            b+=1
        print(int(val+n/2-1))


t = int(input())
for i in range(t):
    n = int(input())
    l = []
    l1 = []
    if n==2:
        print('NO')
    else:
        for i in range(1,n+1):
            if i%2==0:
                l.append(i)
            else:
                l1.append(i)
    if sum(l) > sum(l1):
        while sum(l1) < sum(l):
            l1.append(l1.pop() + 2)
            if sum(l) == sum(l1):
                print('YES')
                print(*(l+l1))
                break
        else:
            print('NO')


t = int(input())
for i in range(t):
    n = int(input())
    l = []
    l1 = []
    if n==2:
        print('NO')
    else:
        for i in range(1,n+1):
            if i%2==0:
                l.append(i)
            else:
                l1.append(i)
    if sum(l) > sum(l1):
        while sum(l1) < sum(l):
            l1.append(l1.pop() + 2)
            if sum(l) == sum(l1):
                print(*(l+l1))

                break
        else:
            print('NO')


t = int(input())
for i in range(t):
    n = int(input())
    arr1 = [x for x in range(1, n+1) if x % 2 == 0]

    avg = sum(arr1) // len(arr1)
    if avg % 2 == 1:
        print("YES")
        arr2 = [avg + 2*x for x in range(-n//4, n//4 + 1) if x != 0]
        print(arr1 + arr2)
    else:
        print("NO")


t = int(input())
for i in range(t):
    n = int(input())
    arr1 = [x for x in range(1, n+1) if x % 2 == 0]

    avg = sum(arr1) // len(arr1)
    if avg % 2 == 1:
        print("YES")
        arr2 = [avg + 2*x for x in range(-n//4, n//4 + 1) if x != 0]
        final = arr1 + arr2
        s = ''
        for f in final:
            s += str(f) + ' '
        print(s)
    else:
        print("NO")


t = int(input())
for i in range(t):
    n = int(input())
    arr1 = [x for x in range(1, n+1) if x % 2 == 0]

    avg = sum(arr1) // len(arr1)
    arr2 = []
    for k in range(-n//4, n//4 + 1):
        if k != 0:
            arr2.append(avg + 2*k)
    cnt = 0
    for a in arr2:
        if a % 2 == 1:
            cnt += 1
    if cnt == len(arr2):
        print("YES")
        final = arr1 + arr2
        s = ''
        for f in final:
            s += str(f) + ' '
        print(s)
    else:
        print("NO")


t = int(input())
for i in range(t):
    n = int(input())
    arr1 = [x for x in range(1, n+1) if x % 2 == 0]

    avg = sum(arr1) // len(arr1)
    if avg % 2 == 1:
        print("YES")
    else:
        print("NO")


t = int(input())
for i in range(t):
    n = int(input())
    arr1 = [x for x in range(1, n+1) if x % 2 == 0]

    avg = sum(arr1) // len(arr1)
    if avg % 2 == 1:
        arr2 = []
        for k in range(-n//4, n//4 + 1):
            if k != 0:
                arr2.append(avg + 2*k)
        cnt = 0
        for a in arr2:
            if a % 2 == 1:
                cnt += 1
        if cnt == len(arr2):
            print("YES")
            final = arr1 + arr2
            s = ''
            for f in final:
                s += str(f) + ' '
            print(s)
        else:
            print("NO")
    else:
        print("NO")


t = int(input())
for i in range(t):
    n = int(input())
    arr1 = [x for x in range(1, n+1) if x % 2 == 0]

    avg = (sum(arr1)) // len(arr1)
    if avg % 2 == 1:
        print("YES")
        arr2 = [avg + 2*x for x in range(-n//4, n//4 + 1) if x != 0]
        final = arr1 + arr2

        print(' '.join(map(str, final)))
    else:
        print("NO")


y=input()
n=int(y);

for i in range (0,n,1):
    import array
    arre=array.array('l',[]);
    arro=array.array('l',[])
    x=input();
    a=int(x);
    o=0;
    l=int(a/2);
    e=0;
    for j in range (2,a+1,2):
         arre.append(j);
         e=e+j;
    #print(*arre);

    for j in range (1,a-1,2):
         arre.append(j);
         pk=j;
         o=o+j;
    c=int(e-o);
    arre.append(c);

    if(a%4!=0):
         print("NO");
    else :
         print("YES");
         print(*arre);


import array
arre=array.array('l',[]);
arro=array.array('l',[])

y=input()
n=int(y);

for i in range (0,n,1):
    x=input();
    a=int(x);
    o=0;
    l=int(a/2);
    e=0;
    for j in range (2,a+1,2):
         arre.append(j);
         e=e+j;

    for j in range (1,a-1,2):
         arre.append(j);
         pk=j;
         o=o+j;
    c=int(e-o);
    arre.append(c);

    if(a%4!=0):
         print("NO");
    else :
         print("YES");
         print(*arre);


import array
arre=array.array('l',[]);
arro=array.array('l',[])

y=input()
n=int(y);

for i in range (0,n,1):
    x=input();
    a=int(x);
    o=0;
    l=int(a/2);
    for j in range (1,a-1,2):
         arro.append(j);
         o=o+j;
    e=0;
    for j in range (2,a+1,2):
         arre.append(j);
         e=e+j;

    if(a%4!=0):
         print("NO");
    else :
         print("YES");
         for j in range (0,l,1):
              print(arre[j]," ");
         for j in range (0,l-1,1):
              print(arro[j]," ");
         c=int(e-o);
         print(c);


def not_valid_number(number: int) -> bool:
    return not ((number / 2) % 2 == 0)

def valid_number_generator(input_number :int) -> str:
    even_set :list= [2]
    odd_set :list= [1]
    for i in range(3, (input_number), 2):
        even_set.append(i+1)
        odd_set.append(i)
    even_sum = int (input_number / 2)
    odd_set[-1] = (even_sum * (even_sum + 1)) + odd_set[-1] \
                  - sum(odd_set)

    return " ".join(map(str, (even_set + odd_set)))

if __name__ == "__main__":
    result = []
    number_of_test: int = int(input())
    while number_of_test > 0:
        input_number : int = int(input())
        if not_valid_number(input_number):
            result.append('NO')
        else:
            result.append('YES')
            result.append(valid_number_generator(
                input_number))

        number_of_test -= 1
    for i in result:
        print(i)


def print_output(array: list):
    for i in array:
        print(i)
def get_output_number(input_number :int):
    even_sum = 2
    odd_sum = 1
    even_set = '2 '
    odd_set = '1 '
    for i in range(3, (input_number - 2), 2):
        even_set = even_set + str(i + 1) + ' '
        even_sum += i + 1

        odd_sum += i
        odd_set = odd_set + str(i) + ' '
    digit_number = int (input_number / 2)
    sum = (digit_number * (digit_number + 1))
    even_set = even_set + str(sum - even_sum) + ' '
    odd_set = odd_set + str(sum - odd_sum)
    return even_set + odd_set

if __name__ == "__main__":
    result = []
    number_of_input: int = int(input())
    while number_of_input > 0:
        input_number = int(input())

        if not (int(input_number / 2) % 2) == 0:
            result.append('NO')
        else:
            result.append('YES')
            result.append(get_output_number(input_number))

        number_of_input -= 1

    print_output(result)


def print_output(array: list):
    for i in array:
        print(i)
if __name__ == "__main__":
    result = []
    number_of_input: int = int(input())
    while number_of_input > 0:
        input_number = int(input())
        even_sum = 0
        odd_sum = 0
        even_set = ''
        odd_set = ''
        digit_number = int(input_number / 2)
        if not (digit_number) % 2 == 0:
            result.append('NO')
        else:
            for i in range(1, int(input_number-1), 2):
                even_set = even_set + str(i+1) + ' '
                even_sum += i + 1

                odd_sum += i
                odd_set = odd_set + str (i) +' '

            sum = (digit_number * (digit_number+ 1))
            even_set = even_set + str(sum - even_sum) + ' '
            odd_set = odd_set + str(sum - odd_sum)
            result.append('YES')
            result.append(even_set+odd_set)

        number_of_input -= 1

    print_output(result)


def not_valid_number(number: int) -> bool:
    return not ((number / 2) % 2 == 0)

def build_array(half_of_test_case: int) -> list:

    first_half: list = [2]
    for i in range(half_of_test_case - 1):
        first_half.append(first_half[-1] + 2)

    second_half: list = [1]
    for i in range(half_of_test_case - 2):
        second_half.append(second_half[-1] + 2)

    sum_of_even = half_of_test_case * (half_of_test_case
                                       + 1)
    sum_of_odd = ((half_of_test_case - 1) * (2 + (
        half_of_test_case - 2) * 2 )) / 2
    second_half.append(int(sum_of_even - sum_of_odd))
    return first_half + second_half

def array_to_space_separated_string(array: list) -> str:
    return " ".join(map(str, array))

def valid_number_generator(n: int) -> str:

    number_array = build_array(int(n/2))
    return array_to_space_separated_string(number_array)

def print_output(array: list):
    for i in array:
        print(i)

if __name__ == "__main__":
    array_length: int = int(input())
    output: list = []

    while array_length > 0:
        test_case = int(input())
        # Invalid number
        if not_valid_number(test_case):
            output.append('NO')
        else:
            string_of_number = valid_number_generator(
                test_case)
            output.append("YES")
            output.append(string_of_number)
        array_length -= 1

    print_output(output)


def not_valid_number(number: int) -> bool:
    return not ((number / 2) % 2 == 0)

def build_first_half_of_array() -> dict:
    first_half: list = [2]
    sum_of_first_half = 2
    for i in range(int(test_case / 2) - 1):
        element = first_half[-1] + 2
        first_half.append(element)
        sum_of_first_half += element

    return dict(array=first_half, sum=sum_of_first_half)

def build_second_half_of_array(sum_of_even_list: int) -> \
        list:
    second_half: list = [1]
    sum_of_second_half = 1
    for i in range(int(test_case / 2 - 2)):
        element = second_half[-1] + 2
        second_half.append(element)
        sum_of_second_half += element
    second_half.append(sum_of_even_list -
                       sum_of_second_half)
    return second_half

def merge_arrays(first_array, second_array) -> list:
    return first_array + second_array

def array_to_space_separated_string(array: list) -> str:
    return " ".join(map(str, array))

def valid_number_generator() -> str:
    even_number_dict = build_first_half_of_array()
    odd_number_list = build_second_half_of_array(
        even_number_dict["sum"])
    number_array = merge_arrays(
        even_number_dict["array"],
        odd_number_list
    )
    return array_to_space_separated_string(number_array)

def print_output(array: list):
    for i in array:
        print(i)

if __name__ == "__main__":
    array_length: int = int(input())
    output: list = []

    while array_length > 0:
        test_case = int(input())
        # Invalid number
        if not_valid_number(test_case):
            output.append('NO')
        else:
            string_of_number = valid_number_generator()
            output.append("YES")
            output.append(string_of_number)
        array_length -= 1

    print_output(output)


def not_valid_number(number: int) -> bool:
    return not ((number / 2) % 2 == 0)

def get_output_number(input_number :int) -> str:
    even_set :list= [2]
    odd_set :list= [1]
    for i in range(3, (input_number), 2):
        even_set.append(i+1)

        odd_set.append(i)

    digit_number = int (input_number / 2)
    odd_set[-1] = (digit_number * (
            digit_number + 1)) + odd_set[-1] - sum(odd_set)

    return " ".join(map(str, (even_set + odd_set)))

def print_output(array: list):
    for i in array:
        print(i)

if __name__ == "__main__":
    result = []
    number_of_input: int = int(input())
    while number_of_input > 0:
        input_number = int(input())
        if not_valid_number(input_number):
            result.append('NO')

        else:
            result.append('YES')
            result.append(get_output_number(
                int(input_number)))

        number_of_input -= 1

    print_output(result)


t = int(input())
for _ in range(t):
    n = int(input())
    if (n//2)%2!=0:
        print("NO")
    else:
        print("YES")
        l =[0]*n
        sc = se =0
        i = 1
        j=1
        while(j<=n//2):
            l[j-1] = i+1
            se += i+1
            if j == n//2:
                l[n-j] = se-sc
                break
            l[n-j] = i
            sc += i
            i+=2
            j+=1
        print(*l, sep=", ")


t = int(input())
for _ in range(t):
    n = int(input())
    if (n//2)%2!=0:
        print("NO")
    else:
        print("YES")
        l =[0]*n
        sc = se =0
        i = 1
        j=1
        while(j<=n//2):
            l[j-1] = i+1
            se += i+1
            if j == n//2:
                l[n-j] = se-sc
                break
            l[n-j] = i
            sc += i
            i+=2
            j+=1
        print(*l, sep=" ")


t = int(input())
for _ in range(t):
    n = int(input())
    if (n//2)%2!=0:
        print("NO")
    else:
        print("YES")
        l =[0]*n
        sc = se =0
        i = 1
        j=1
        while(j<=n//2):
            l[j-1] = i+1
            se += i+1
            if j == n//2:
                l[n-j] = se-sc
                break
            l[n-j] = i
            sc += i
            i+=2
            j+=1
        print(l)


for tt in range(int(input())):
    n=int(input())
    if(n==2):
        print('NO',end='')
    else:
        l,e,o,p=[],2,1,0
        while(p<n/2):
            l.append(e)
            e+=2
            p+=1
        sm,smo,lo=sum(l),0,[]
        while(smo<sm):
            lo.append(o)
            smo+=o
            o+=2

        if((smo-sm)%2==0 or (smo-sm) not in lo):
            print('NO',end='')
        else:
            lo.remove(smo-sm)
            print('YES')
            for i in l:
                print(i,end=' ')
            for i in lo:
                print(i,end=' ')
    print()


for tt in range(int(input())):
    n=int(input())
    if(n==2):
        print('NO',end='')
    else:
        mll,ce,o,p=[],2,1,0
        while(p<n/2):
            mll.append(ce)
            ce+=2
            p+=1
        sumeven,sumod,listodd=sum(mll),0,[]
        while(sumod<sumeven):
            listodd.append(o)
            sumod+=o
            o+=2

        if((sumod-sumeven)%2==0 or (sumod-sumeven) not in listodd):
            print('NO',end='')
        else:
            listodd.remove(sumod-sumeven)
            print('YES')
            for i in mll:
                print(i,end=' ')
            for i in listodd:
                print(i,end=' ')
    print()


for tt in range(int(input())):
    n=int(input())
    if(n==2):
        print('NO',end='')
    else:
        mlist,e,o,p=[],2,1,0
        while(p<n/2):
            mlist.append(e)
            e+=2
            p+=1
        sumeven,sumodd,listodd=sum(mlist),0,[]
        while(sumodd<sumeven):
            listodd.append(o)
            sumodd+=o
            o+=2

        if((sumodd-sumeven)%2==0 or (sumodd-sumeven) not in listodd):
            print('NO',end='')
        else:
            listodd.remove(sumodd-sumeven)
            print('YES')
            for i in mlist:
                print(i,end=' ')
            for i in listodd:
                print(i,end=' ')
    print()


for tt in range(int(input())):
    n=int(input())
    if(n==2):
        print('NO',end='')
    else:
        l,e,o,p=[],2,1,0
        while(p<n/2):
            l.append(e)
            e+=2
            p+=1
        se,so,listodd=sum(l),0,[]
        while(so<se):
            listodd.append(o)
            so+=o
            o+=2

        if((so-se)%2==0 or (so-se) not in listodd):
            print('NO',end='')
        else:
            listodd.remove(so-se)
            print('YES')
            for i in l:
                print(i,end=' ')
            for i in listodd:
                print(i,end=' ')
    print()


for _ in range(int(input())):
    n = int(input())
    ans = []
    if(n%4 != 0):
        print('NO')
    else:
        ach = 0
        for i in range(2,n+1,2):
            ans.append(str(i))
            ach += i
        cnt = int(n)
        tsum = 0
        for i in range(1, n-1,2):
            tsum+=i
            ans.append(str(i))
            x = i
        while(tsum < ach):
            x+=2
            if(tsum+x==ach):
                ans.append(str(x))
                break
        print('YES')
        print(' '.join(ans))


for _ in range(int(input())):
    n = int(input())
    nums  = []
    if(n//2%2 != 0):
        print('NO')
    else:
        for i in range(1,n+1):
            if(i%2 == 0):
                nums.insert(0, i)
            else:
                nums.append(i)
        nums[n-1] +=  n//2
        print('YES')
        print(' '.join(map(str, nums)))


for _ in range(int(input())):
    n = int(input())
    nums  = []
    if(n%4 != 0):
        print('NO')
    else:
        for i in range(1,n+1):
            if(i%2 == 0):
                nums.insert(0, i)
            else:
                nums.append(i)
        nums[n-1] =  n-1+n//2
        print('YES')
        print(' '.join(map(str, nums)))


for _ in range(int(input())):
    n = int(input())
    nums  = []
    if(n//2%2 != 0):
        print('NO')
    else:
        for i in range(1,n+1):
            if(i%2 == 0):
                nums.insert(0, i)
            else:
                nums.append(i)
        nums[n-1] =  n-1+n//2
        print('YES')
        print(' '.join(map(str, nums)))


t=int(input())
for _ in range (t):
    n=int(input())
    if n%4==2:
    	print("NO")
    else:
    	print("YES")
    	e=[2]
    	o=[1]
    	so=0
    	se=0
    	for i in range(n//2-1):
    		e.append(max(e)+2)
    	for i in range(len(e)):
    		se+=e[i]
    	for i in range (n//2-2):
    		o.append(max(o)+2)
    	for i in range(len(o)):
    		so+=o[i]
    	o.append(se-so)
    	l=e+o
    	for i in range(n):
    		print(l[i], end=" ")


t=int(input())
for _ in range (t):
    n=int(input())
    if n%4==2:
        print("NO")
    else:
        print("YES")
        e=[2]
        o=[1]
        so=1
        se=2
        for i in range(n//2-2):
            e.append(e[-1]+2)
            se+=e[-1]
            o.append(o[-1]+2)
            so+=o[-1]
        e.append(e[-1]+2)
        se+=e[-1]
        o.append(se-so)
        l=e+o
        for i in range(n):
            print(l[i], end=" ")


t=int(input())
for _ in range (t):
    n=int(input())
    if n%4==2:
        print("NO")
    else:
        print("YES")
        e=[2]
        o=[1]
        so=1
        se=2
        for i in range(n//2-1):
            e.append(max(e)+2)
            se+=e[-1]
        for i in range (n//2-2):
            o.append(max(o)+2)
            so+=o[-1]
        o.append(se-so)
        l=e+o
        for i in range(n):
            print(l[i], end=" ")


t=int(input())
for _ in range(t):
    n=int(input())
    if n%4==2:
    	print("NO")
    else:
    	print("YES")
    	e=[2]
    	o=[1]
    	so=0
    	se=0
    	for i in range(n//2-1):
    		e.append(max(e)+2)
    	for i in range(len(e)):
    		se+=e[i]
    	for i in range (n//2-2):
    		o.append(max(o)+2)
    	for i in range(len(o)):
    		so+=o[i]
    	o.append(se-so)
    	print(e+o)


t=int(input())
for _ in range (t):
    n=int(input())
    if n%4==2:
    	print("NO")
    else:
    	print("YES")
    	e=[2]
    	o=[1]
    	so=1
    	se=2
    	for i in range(n//2-1):
    	    e.append(max(e)+2)
    	    se+=e[-1]
    	for i in range (n//2-2):
    	    o.append(max(o)+2)
    	    so+=o[-1]
    	o.append(se-so)
    	for i in range(n):
    		print(e+o[i], end=" ")


import math
t=int(input())
for i in range(t):
    n=int(input())
    if math.ceil(math.log(n,2))==math.floor(math.log(n,2)) and n!=2:
        ans=[]
        ans1=[]
        i1=3
        i2=2*n-1
        x1=2
        x2=2*n
        while(len(ans)<n//2):
            ans.append(i1)
            ans.append(i2)
            i1+=2
            i2-=2
            ans1.append(x1)
            ans1.append(x2)
            x1+=2
            x2-=2
        c=ans1+ans
        print("YES")
        print(*c)
    else:
        print("NO")


import math
t=int(input())
for i in range(t):
    n=int(input())
    if 1==1:
        ans=[]
        ans1=[]
        i1=3
        i2=2*n-1
        x1=2
        x2=2*n
        sum1=0
        sum2=0
        if n==2 or (n//2)%2 ==1:
            print("NO")
            continue

        while(len(ans)<n//2 and x1<x2 and i1<i2):
            ans.append(i1)
            ans.append(i2)
            sum1+=i1+i2
            i1+=2
            i2-=2
            ans1.append(x1)
            ans1.append(x2)
            sum2+=x1+x2
            x1+=2
            x2-=2
            if len(ans)==n//2:
                break
        c=ans1+ans
        if sum1==sum2:
            print("YES")
            print(*c)
        else:
            print("NO")


import math
t=int(input())
for i in range(t):
    n=int(input())
    if math.ceil(math.log(n,2))==math.floor(math.log(n,2)) and n!=2:
        ans=[]
        ans1=[]
        i1=3
        i2=2*n-1
        x1=2
        x2=2*n
        while(len(ans)<n//2):
            ans.append(i1)
            ans.append(i2)
            i1+=2
            i2-=2
            ans1.append(x1)
            ans1.append(x2)
            x1+=2
            x2-=2
        c=ans+ans1
        print("YES")
        print(*c)
    else:
        print("NO")


cases = int(input())

for case in range(cases):
  size = int(input())
  if (size/2)%2 == 0:
    amt = int(size/2)
    evenArray = []
    oddArray = []
    for y in range(1,amt+1):
      evenArray.append(y*2)
    for z in range(1,amt):
      oddArray.append(z*2-1)
    oddArray.append(sum(evenArray)-sum(oddArray))
    totalArray = []
    totalArray+=evenArray+oddArray
    s = ""
    for x in totalArray:
      s+= str(x) + " "
    print("YES")
    print(s.strip())
  else:
    print("NO")


import sys
cases = int(input())

for case in range(cases):
  size = int(input())
  if (size/2)%2 == 0:
    print("YES")
    amt = int(size/2)
    evenArray = []
    oddArray = []
    for y in range(1,amt+1):
      sys.stdout.write(str(y*2) + " ")
    for z in range(1,amt):
      sys.stdout.write(str(z*2-1) + " ")
    sys.stdout.write(str(sum(evenArray)-sum(oddArray)))
  else:
    print("NO")


cases = int(input())

for case in range(cases):
  size = int(input())
  if (size/2)%2 == 0:
    amt = int(size/2)
    evenArray = []
    oddArray = []
    for y in range(1,amt+1):
      evenArray.append(y*2)
    for z in range(1,amt):
      oddArray.append(z*2-1)
    oddArray.append(sum(evenArray)-sum(oddArray))
    totalArray = []
    totalArray+=evenArray+oddArray
    s = ""
    for x in totalArray:
      s+= str(x) + " "
    print(s.strip())
  else:
    print("NO")


n = int(input())
a = [ int(s) for s in input().split()]
b = []
c = 0
m = max(a)
s = sum(a)-2*m
for i in range(n):
	if a[i] == s and a[i] != m:
		b.append(i+1)
		c += 1

a[a.index(m)] = 0
m2 = max(a)
if sum(a)-2*m2 == 0:
	c += 1
	b.append(a.index(0)+1)
print(c)
print(' '.join(map(str, b)))


n = int(input())
a = [int(s) for s in input().split()]
s = sum(a)
ids = []
i, l = 0, 0
raznost = s - 2*max(a)
if raznost in a:
    while i < a.count(raznost):
        ids.append(a.index(raznost, l)+1)
        i+=1
        l = ids[-1]
if (s - max(a))//2 in a and  (s - max(a))%2 == 0:
    i += 1
    ids.append(a.index(max))
print(i)
print(" ".join(map(str, ids)))


n = int(input())
a = [int(s) for s in input().split()]
s = sum(a)
ind = []
i, st, k = 0, 0, 0
def proverka(st = 0, n = 0):
	global i, k
	for i in range(st, n):
		if (s-a[i]) // 2 in a and (s-a[i]) % 2 == 0:
			ind.append(i)
			k += 1
			return i
	print(k)
	print(" ".join(map(str, ind)))

	return -1
while proverka(st, n) != -1:
	st = i + 1


n = int(input())
a = [ int(s) for s in input().split()]
b = []
c = 0
m = max(a)
s = sum(a)-2*m
if n == 3:
	if a[0] == a[1] == a[2]:
		print(3)
		print(' '.join(map(str, a)))
else:
	for i in range(n):
		if a[i] == s and a[i] != m:
			b.append(i+1)
			c += 1

	a[a.index(m)] = 0
	m2 = max(a)
	if sum(a)-2*m2 == 0:
		c += 1
		b.append(a.index(0)+1)
	print(c)
	print(' '.join(map(str, b)))


n = int(input())
a = [ int(s) for s in input().split()]
b = []
b = list(a)
b.sort()
ids = []
r = sum(b) - 2*b[-1]
i, j = 0, 0
if r in b:
	if r == b[-1] and b[-2] != b[-1]:
		print(0)
	else:
		while i < len(a):
			if a[i] == r:
				ids.append(i+1)
				j+=1
			i+=1
		if (sum(a) - b[-1])//2 == b[-2] and (sum(a) - b[-1])%2 == 0:
			if a.index(b[-1])+1 not in ids:
				ids.append(a.index(b[-1])+1)
				j+=1
		print(j)
		print(" ".join(map(str, ids)))
elif (sum(a) - b[-1])//2 == b[-2] and (sum(a) - b[-1])%2 == 0:
	ids.append(a.index(b[-1]))
	print(1)
	print(ids[0]+1)
else:
	print(0)


n = int(input())
a = [ int(s) for s in input().split()]
kr = []
s = sum(a)
for i in range(n):
	if ((s - a[i]) // 2) in a and ((s-a[i]) % 2 == 0 and a[i] != ((s - a[i]) // 2)):
		kr.append(i+1)
l = len(kr)
print(l)
kr = list(map(str, kr))
print(' '.join(kr))


n = int(input())
a = [ int(s) for s in input().split()]
b = []
b = list(a)
b.sort()
ids = []
r = sum(b) - 2*b[-1]
i, j = 0, 0
if r in b:
	if r == b[-1] and b[-2] != b[-1]:
		print(0)
	else:
		while i < len(a):
			if a[i] == r:
				ids.append(i+1)
				j+=1
			i+=1
		if (sum(a) - b[-1])//2 == b[-2] and (sum(a) - b[-1])%2 == 0:
			if a.index(b[-1])+1 not in ids:
				ids.append(a.index(b[-1])+1)
				j+=1
		print(j)
		print(" ".join(map(str, ids)))
else:
	print(0)


n =3# int(input())
a = [ int(s) for s in "4 4 4".split()]
b = []
b = list(a)
b.sort()
ids = []
r = sum(b) - 2*b[-1]
i, j = 0, 0
if r in b:
	if r == b[-1] and b[-2] != b[-1]:
		print(0)
	else:
		while i < len(a):
			if a[i] == r:
				ids.append(i+1)
				j+=1
			i+=1
		if (sum(a) - b[-1])//2 == b[-2] and (sum(a) - b[-1])%2 == 0:
			if a.index(b[-1])+1 not in ids:
				ids.append(a.index(b[-1])+1)
				j+=1
		print(j)
		print(" ".join(map(str, ids)))
else:
	print(0)


n = int(input())
a = [int(s) for s in input().split()]
def f(a, r):
    if a == r:
        return a

ids = []
i, l = 0, 0
raznost = sum(a) - 2*max(a)
if a.count(max(a)) == 1 and raznost == max(a):
    print(0)
else:
    if raznost in a:
        while i < a.count(raznost) and i < 30:
            ids.append(a.index(raznost, l)+1)
            i+=1
            l = ids[-1]
    if (sum(a) - max(a))//2 in a and  (sum(a) - max(a))%2 == 0:
        i += 1
        ids.append(a.index(max(a))+1)
    print(i)
    if i > 0:
        print(" ".join(map(str, ids)))


n = int(input())
a = [ int(s) for s in input().split()]
kr = []
s = sum(a)
for i in range(n):
	if ((s - a[i]) // 2) in a and (s-a[i]) % 2 == 0:
		if a[i] != ((s - a[i]) // 2):
			kr.append(i+1)
print(len(kr))
print(' '.join(list(map(str, kr))))


n = int(input())
a = [int(s) for s in input().split()]
s = sum(a)
ids = []
i, l = 0, 0
raznost = s - 2*max(a)
if raznost in a:
    while i < a.count(raznost):
        ids.append(a.index(raznost, l)+1)
        i+=1
        l = ids[-1]
if (s - max(a))//2 in a and  (s - max(a))%2 == 0:
    i += 1
    ids.append(a.index(max(a))+1)
print(i)
print(" ".join(map(str, ids)))


n = int(input())
a = [ int(s) for s in input().split()]
b = []
b = list(a)
b.sort()
ids = []
r = sum(b) - 2*b[-1]
i, j = 0, 0
if r in b:
	if r == b[-1] and b[-2] != b[-1]:
		print(0)
	else:
		while i < len(a):
			if a[i] == r:
				ids.append(i+1)
				j+=1
			i+=1
		if (sum(a) - b[-1])//2 == b[-2] and (sum(a) - b[-1])%2 == 0:
			ids.append(a.index(b[-1])+1)
			j+=1
		print(j)
		print(" ".join(map(str, ids)))
else:
	print(0)


n = int(input())
a = [ int(s) for s in input().split()]
kr = []
s = sum(a)
for i in range(n):
	if ((s - a[i]) // 2) in a and ((s-a[i]) % 2 == 0 and a[i] != ((s - a[i]) // 2)):
		kr.append(i+1)
print(len(kr))
print(' '.join(list(map(str, kr))))


n = int(input())
a = [int(s) for s in input().split()]
s = sum(a)
ind = []
i, st, k = 0, 0, 0
def proverka(st = 0, n = 0):
	global i, k
	for i in range(st, n):
		r = a[i]
		a[i] = 0
		if (s-r) // 2 in a and (s-r) % 2 == 0:
			ind.append(i + 1)
			k += 1
			a[i] = r
			return i
		a[i] = r
	print(k)
	if k > 0:
		print(" ".join(map(str, ind)))

	return -1
while proverka(st, n) != -1:
	st = i + 1


n = int(input())
a = [int(s) for s in input().split()]
s = sum(a)
ids = []
i, l = 0, 0
raznost = s - 2*max(a)
if a.count(max(a)) == 1 and raznost == max(a):
    print(0)
else:
    if raznost in a:
        while i < a.count(raznost) and i < 30:
            ids.append(a.index(raznost, l)+1)
            i+=1
            l = ids[-1]
    if (s - max(a))//2 in a and  (s - max(a))%2 == 0:
        i += 1
        ids.append(a.index(max(a))+1)
    print(i)
    if i > 0:
        print(" ".join(map(str, ids)))


n = int(input())
a = [ int(s) for s in input().split()]
b = []
b = list(a)
b.sort()
ids = []
r = sum(b) - 2*b[-1]
i = 0
if r in b:
	if r == b[-1] and b[-2] != b[-1]:
		print(0)
	else:
		while i < a.count(r):
			if a[i] == r:
				ids.append(i)
			i+=1
		if (sum(a) - b[-1])//2 == b[-2] and (sum(a) - b[-1])%2 == 0:
			ids.append(a.index(b[-2]))
			i+=1
		print(i)
		print(" ".join(map(str, ids)))
else:
	print(0)


n = int(input())
a = [int(s) for s in input().split()]
s = sum(a)
ind = []
i, st, k = 0, 0, 0
def proverka(st = 0, n = 0):
	global i, k
	for i in range(st, n):
		if (s-a[i]) // 2 in ([a[:i]]+a[i+1:]) and (s-a[i]) % 2 == 0:
			ind.append(i + 1)
			k += 1
			return i
	print(k)
	if k > 0:
		print(" ".join(map(str, ind)))

	return -1
while proverka(st, n) != -1:
	st = i + 1


n = int(input())
a = [ int(s) for s in input().split()]
b = []
c = 0
m = max(a)
s = sum(a)-2*m
if n == 3:
	if a[0] == a[1] == a[2]:
		print(3)
		print('1 2 3')
else:
	for i in range(n):
		if a[i] == s and a[i] != m:
			b.append(i+1)
			c += 1

	a[a.index(m)] = 0
	m2 = max(a)
	if sum(a)-2*m2 == 0:
		c += 1
		b.append(a.index(0)+1)
	print(c)
	print(' '.join(map(str, b)))


n = int(input())
a = [ int(s) for s in input().split()]
b = []
b = list(a)
b.sort()
ids = []
r = sum(b) - 2*b[-1]
i, j = 0, 0
if r in b:
	if r == b[-1] and b[-2] != b[-1]:
		print(0)
	else:
		while i < len(a):
			if a[i] == r:
				ids.append(i+1)
				j+=1
			i+=1
		if (sum(a) - b[-1])//2 == b[-2] and (sum(a) - b[-1])%2 == 0:
			ids.append(a.index(b[-2]))
			j+=1
		print(j)
		print(" ".join(map(str, ids)))
else:
	print(0)


n = int(input())
a = [ int(s) for s in input().split()]
b = []
b = list(a)
b.sort()
print(b)
ids = []
r = sum(b) - 2*b[-1]
i = 0
if r in b:
	if r == b[-1] and b[-2] != b[-1]:
		print(0)
	else:
		while i < a.count(r):
			i+=1
			if a[i] == r:
				ids.append(i)
		if (sum(a) - b[-1])//2 == b[-2] and (sum(a) - b[-1])%2 == 0:
			ids.append(a.index(b[-2]))
			i+=1
		print(i)
		print(" ".join(map(str, ids)))
else:
	print(0)


n=int(input())
a=[int(i)for  i in input().split()]
s=sum(a)//2
b=[[a[i-1],i]for i in range(1,n+1)]
b.sort()
for i in range(1,n):
    if b[i-1][0]<=s<=b[i][0]:
        k=i-1
        break
else:
    k=n-1
ans=[]
num=0
for i in range(n):
    while k>=0 and b[k][0]>s-b[i][0]/2:
        k-=1
    if k==-1:
        break
    if b[k][0]==s-b[i][0]/2:
        if k==i:
            if b[k-1][0]==b[k][0]:
                ans.append(b[i][1])
                num+=1
        else:
            ans.append(b[i][1])
            num+=1
print(num)
print(' '.join([str(r)for r in ans]))


n=int(input())
a=[int(i)for  i in input().split()]
s=sum(a)/2
b=[[a[i-1],i]for i in range(1,n+1)]
b.sort()
for i in range(1,n):
    if b[i-1][0]<=s<=b[i][0]:
        k=i-1
        break
else:
    k=n-1
ans=[]
num=0
for i in range(n):
    while k>=0 and b[k][0]>s-b[i][0]/2:
        k-=1
    if k==-1:
        break
    if b[k][0]==s-b[i][0]/2:
        if k==i:
            if b[k-1][0]==b[k][0]:
                ans.append(b[i][1])
                num+=1
        else:
            ans.append(b[i][1])
            num+=1
print(num)
print(' '.join([str(r)for r in ans]))


n = int(input())
if n == 2:
  print(0)
  print()
else:
  ns = [int(m) for m in input().split()]
  idxs = []
  s = sum(ns)
  m = max(ns)
  m2 = max(n for n in ns if n != m)
  for idx, num in enumerate(ns):
    if num != m:
      if s-m-num == m:
        idxs.append(idx+1)
    else:
      if s-m2-num == m2:
        idxs.append(idx+1)

  print(len(idxs))
  print(*idxs)


n = int(input())
ns = [int(m) for m in input().split()]
idxs = []
s = sum(ns)
m = max(ns)
m2 = max(n for n in ns if n != m)
for idx, num in enumerate(ns):
  if num != m:
    if s-m-num == m:
      idxs.append(idx)
  else:
    if s-m2-num == m2:
      idxs.append(idx)

print(len(idxs))
print(*idxs)


n = int(input())
ns = [int(m) for m in input().split()]
idxs = []
s = sum(ns)
m = max(ns)
m2 = max(n for n in ns if n != m)
for idx, num in enumerate(ns):
  if num != m:
    if s-m-num == m:
      idxs.append(idx+1)
  else:
    if s-m2-num == m2:
      idxs.append(idx+1)

print(len(idxs))
print(*idxs)


n = int(input())
ns = [int(m) for m in input().split()]
idxs = []
s = sum(ns)
m = max(ns)
m2 = max([n for n in ns if n != m] or [m])
for idx, num in enumerate(ns):
  if num != m:
    if s-m-num == m:
      idxs.append(idx+1)
  else:
    if s-m2-num == m2:
      idxs.append(idx+1)

print(len(idxs))
print(*idxs)


n = int(input())
ns = [int(m) for m in input().split()]
idxs = []
s = sum(ns)
m2, m = sorted(ns)[-2:]
for idx, num in enumerate(ns):
  if num != m:
    if s-m-num == m:
      idxs.append(idx+1)
  else:
    if s-m2-num == m2:
      idxs.append(idx+1)

print(len(idxs))
print(*idxs)


n = int(input())
ns = [int(m) for m in input().split()]
idxs = []
s = sum(ns)
m, m2 = sorted(ns)[-2:]
for idx, num in enumerate(ns):
  if num != m:
    if s-m-num == m:
      idxs.append(idx+1)
  else:
    if s-m2-num == m2:
      idxs.append(idx+1)

print(len(idxs))
print(*idxs)


#!/usr/bin/env python3
import sys

n = int(sys.stdin.readline())
a = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))

res = []
s = sum(a)
m1 = max(a)
if a.count(m1) > 3:
    print(0)
elif a.count(m1) == 3 and len(a) == 3:
    print(3)
    print('1 2 3')
elif a.count(m1) == 2 and s - 2 * m1 == m1:
    print(2)
    print(' '.join([str(i + 1) for i, e in enumerate(a) if e == m1]))
else:
    m1i = a.index(m1)
    a2 = list(a)
    a2.remove(m1)
    m2 = max(a2)
    res = []
    if sum(a2) - m2 == m2:
        res.append(m1i)
    for i in range(n):
        if i != m1i and s - m1 - a[i] == m1:
            res.append(i)
    print(len(res))
    print(' '.join([str(e + 1) for i, e in enumerate(res)]))


#!/usr/bin/env python3
import sys

n = int(sys.stdin.readline())
a = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))

res = []
for i in range(n):
    a2 = list(a)
    del a2[i]
    m = max(a2)
    a2.remove(m)
    if sum(a2) == m:
        res.append(i)

# s = sum(a)
# m1 = max(a)
# a2 = list(a)
# a2.remove(m1)
# m2 = max(a2)
# a3 = list(a2)
# a3.remove(m2)
# m3 = max(a3)
#
# if m1 == m2 and
# res = []
# for i in range(n):
#     if m1 == s - a[i] - m1 or m2 == s - a[i] - m2:
#         res.append(i)
print(len(res))
print(' '.join(list(map(lambda x: str(x + 1), res))))


#!/usr/bin/env python3
import sys

n = int(sys.stdin.readline())
a = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))

res = []
s = sum(a)
m1 = max(a)
if a.count(m1) > 2:
    print(0)
elif a.count(m1) == 2 and s - 2 * m1 == m1:
    print(2)
    print(' '.join([str(i + 1) for i, e in enumerate(a) if e == m1]))
else:
    m1i = a.index(m1)
    a2 = list(a)
    a2.remove(m1)
    m2 = max(a2)
    res = []
    if sum(a2) - m2 == m2:
        res.append(m1i)
    for i in range(n):
        if i != m1i and s - m1 - a[i] == m1:
            res.append(i)
    print(len(res))
    print(' '.join([str(e + 1) for i, e in enumerate(res)]))


n=int(input())
a=list(map(int,input().split(' ')))
s=sum(a)
m=max(a)
m1=0
for i in range(len(a)):
    if a[i]!=m:
        if a[i]>m1:
            m1=a[i]

b=[]
for i in range(len(a)):
    if a[i]==m:
        s=s-a[i]
        if s==2*m1:
            b.append(i+1)
        s+=a[i]
    else:
        s=s-a[i]
        if s==2*m:
            b.append(i+1)
        s+=a[i]
if len(b)==0:
    print(0)
else:
    print(len(b))
    print(*b)


n=int(input())
a=list(map(int,input().split(' ')))
s=sum(a)
m=max(a)
ind=a.index(m)
m1=0
for i in range(len(a)):
    if i!=ind:
        if a[i]>m1:
            m1=a[i]

b=[]
for i in range(len(a)):
    if a[i]==m:
        s=s-a[i]
        if s==2*m1:
            b.append(i+1)
        s+=a[i]
    else:
        s=s-a[i]
        if s==2*m:
            b.append(i+1)
        s+=a[i]
if len(b)==0:
    print(0)
else:
    print(len(b))
    print(*b)


# maa chudaaye duniya
n = int(input())
arr = list(map(int,input().split()))
s = sum(arr)
d = {}
for i in arr:
    if i in d:
        d[i]+=1
    else:
        d[i] = 1
ans = []
for i in range(n):
    t = s-arr[i]
    if t%2!=0:
        continue
    else:
        req = t//2
        if arr[i]==req:
            if req in d:
                if d[req]>=2:
                    ans.append(i+1)
                else:
                    pass
        else:
            if req in d:
                if d[req]>=1:
                    ans.append(i+1)
print(len(ans))
print(*ans)


# maa chudaaye duniya
n = int(input())
arr = list(map(int, input().split()))
mp = {}
su = 0
for i in range(n):
    su += arr[i]
    if arr[i] in mp:
        mp[arr[i]].append(i+1)
    else:
        mp[arr[i]] = [i+1]
xset = list(set(arr))
a = []
for i in range(len(xset)):
    for j in range(len(xset)):
        if i!= j:
            remainder = su - xset[i]
            if xset[j] == remainder - xset[j]:
                a += mp[xset[i]]
print(len(a))
print(*a)


def C():

	n = int(input())
	array = [int(x) for x in input().split()]
	total_sum = sum(array)

	count = [0]*1000002
	for element in array: count[element]+=1

	ans = []

	for i in range(n):

		count[array[i]]-=1
		partial_sum = total_sum - array[i]

		if(partial_sum%2==0 and count[partial_sum//2]>0):
			ans.append(str(i+1))

		count[array[i]]+=1

	print(len(ans))
	print(" ".join(ans))

C()


def C():

	n = int(input())
	array = [int(x) for x in input().split()]
	total_sum = sum(array)

	count = [0]*1000002
	for element in array: count[element]+=1

	ans = []

	for i in range(n):

		count[array[i]]-=1
		partial_sum = total_sum - array[i]

		if(partial_sum%2==0 and int(t/2)<1000007 and count[partial_sum//2]>0):
			ans.append(str(i+1))

		count[array[i]]+=1

	print(len(ans))
	print(" ".join(ans))

C()


def is_good(array):

	total_sum = sum(array)

	if(total_sum%2): return False

	return True if(total_sum//2 in array) else False

def C():

	n = int(input())
	array = [int(x) for x in input().split()]

	count = 0
	ans = []

	for i in range(len(array)):
		if(is_good(array[:i]+array[i+1:])):
			count+=1
			ans.append(str(i+1))

	print(count)
	print(" ".join(ans))

C()


def C():

	n = int(input())
	array = [int(x) for x in input().split()]
	total_sum = sum(array)

	count = [0]*1000002
	for element in array: count[element]+=1

	ans = []

	for i in range(n):

		count[array[i]]-=1
		partial_sum = total_sum - array[i]

		if(partial_sum%2==0 and int(partial_sum/2)<1000007 and count[partial_sum//2]>0):
			ans.append(str(i+1))

		count[array[i]]+=1

	print(len(ans))
	print(" ".join(ans))

C()


def is_good(array):

	total_sum = sum(array)

	array = set(array)

	if(total_sum%2): return False

	return True if(total_sum//2 in array) else False

def C():

	n = int(input())
	array = [int(x) for x in input().split()]

	count = 0
	ans = []

	for i in range(len(array)):
		if(is_good(array[:i]+array[i+1:])):
			count+=1
			ans.append(str(i+1))

	print(count)
	print(" ".join(ans))

C()


n=int(input());a=list(map(int,input().split()))
if n>2:
    r=sum(a);q=sorted(set(a))
    q,w=q[-1],q[-2];l=[]
    for i in range(n):
        x=r-a[i]
        if a[i]!=q:
            if x/q==2:
                l.append(i+1)
        else:
            if x/w==2:
                l.append(i+1)
else:
    l=[1,2]
print(len(l))
print(*l)


n=int(input());a=list(map(int,input().split()))
r=sum(a);q=sorted(set(a))
q,w=q[-1],q[-2];l=[]
for i in range(n):
    x=r-a[i]
    if a[i]!=q:
        if x/q==2:
            l.append(i+1)
    else:
        if x/w==2:
            l.append(i+1)
print(len(l))
print(*l)


n = int(input())
seq=list(map(int,input().split()))
mx = max(seq)
sm = sum(seq)
nseq = [seq[i] for i in range(n)]
nseq.remove(mx)
mx2 = max(nseq)
ans = []
for i in range(n):
	s = seq[i]
	if s == mx:
		if sm-s == 2*mx2:
			ans.append(i+1)
	else:
		if sm-s == 2*mx:
			ans.append(i+1)
print(len(ans))
print(" ".join(list(map(str, ans))))


n=int(input());a=list(map(int,input().split()))
r=sum(a);q=sorted(set(a))
q,w=q[-1],q[-2];l=""
for i in range(n):
    x=r-a[i]
    if a[i]!=q:
        if x/q==2:
            l+=str(i+1)+" "
    else:
        if x/w==2:
            l+=str(i+1)+" "
print(len(l)//2)
print(l)


n=int(input());a=list(map(int,input().split()));l=[]
if n>2:
    r=sum(a);q=sorted(set(a))
    q,w=q[-1],q[-2]
    for i in range(n):
        x=r-a[i]
        if a[i]!=q:
            if x/q==2:
                l.append(i+1)
        else:
            if x/w==2:
                l.append(i+1)
print(len(l))
print(*l)


n=int(input())
l=list(map(int, input().split()))
b=len(l)
d=0
k=0
m=[]
s=sum(l)
for i in range(b):
    d=s- l[i]
    for j in range(b):
        if(i==j):
            continue
        else:
            k=d-l[j]
            if(k==l[i]):
                m.append(j+1)
print(len(m))
print(' '.join(map(str,m)))


n=int(input())
l=list(map(int , input().split()))
w=max(l)
maxpos=l.index(w)
k=sum(l)-l[maxpos]
m=[]
for i in range(n):
	d=k-l[i]
	if(i==maxpos):
		continue
	elif(w==d):
		m.append(i+1)
l[maxpos]=0
w=max(l)
k=sum(l)-w
if(k==w):
	m.append(maxpos+1)
print(len(m))
print(' '.join(map(str,m)))


n=int(input())
e=[]
a=[int(z)for z in input().split()]
for i in range(n):
    ai,a[i]=a[i],0
    if max(a)*2==sum(a):
        e.append(i+1)
    a[i]=ai
print(len(e))
if len(e):
    print(*e,sep=' ')


input()
a=[*map(int, input().split())]
s=sum(a)
h=sorted(a)[-2:]
r=[i for i,x in enumerate(a,1)if s-x==2*h[x!=h[1]]]
print(len(r))
print(*r)
###################The one below gets TimeLimitExceeded
#n=int(input())
#e=[]
#a=[int(z)for z in input().split()]
#for i in range(n):
#    ai,a[i]=a[i],0
#    if max(a)*2==sum(a):
#        e.append(i+1)
#    a[i]=ai
#print(len(e))
#if len(e):
#    print(*e,sep=' ')


def is_good_array(array, removed_element, sum_of_array, current_max_element):

    if removed_element == current_max_element:
        current_max_element = max(array)

    return current_max_element == (sum_of_array - current_max_element - removed_element)

input()  # array len
array = list(map(int, input().split(' ')))

sum_of_array = sum(array)
current_max_element = max(array)

counter = 0
saved_indexes = []

for index, each in enumerate(array):
    removed_element = array[index]
    array[index] = 0

    if is_good_array(array, removed_element, sum_of_array, current_max_element):
        counter += 1
        saved_indexes.append(index + 1)

    array[index] = removed_element

print(counter)
for each in saved_indexes:
    print(each)


input()  # array len
array = list(map(int, input().split(' ')))

sum_of_array = sum(array)
second_max, first_max = sorted(array)[-2:]

answer = []

for index, each in enumerate(array, 1):

    existing_sum = sum_of_array - each
    existing_max = second_max if each == first_max else first_max

    if existing_sum == existing_max * 2:
        answer.append(index)

print(len(answer))
print(*answer)


def is_good_array(array, sum_of_array):

    max_value = max(array)

    return max_value == (sum_of_array - max_value)

input()  # array len
array = list(map(int, input().split(' ')))

sum_of_array = sum(array)

counter = 0
saved_indexes = []

for index, each in enumerate(array):
    removed_element = array[index]
    array[index] = 0

    if is_good_array(array, sum_of_array - removed_element):
        counter += 1
        saved_indexes.append(index + 1)

    array[index] = removed_element

print(counter)
for each in saved_indexes:
    print(each)


from collections import Counter
MAX = 10**6
n = int(input())
nums = [int(v) for v in input().split()]
other_nums = Counter(nums)
mysum = sum(nums)
result = []
for i, val in enumerate(nums, 1):
    mysum -= val
    if not mysum % 2 and mysum / 2 <= MAX and other_nums.get(mysum/2):
        result.append(str(i))
    mysum += val

print(len(result))
print(' '.join(result))


from collections import Counter
MAX = 10**6
n = int(input())
nums = [int(v) for v in input().split()]
other_nums = Counter(nums)
mysum = sum(nums)
result = []
for i, val in enumerate(nums, 1):
    mysum -= val
    if not mysum % 2 and mysum / 2 <= MAX and other_nums.get(mysum/2) > 0:
        result.append(str(i))
    mysum += val

print(len(result))
print(' '.join(result))


from collections import Counter
MAX = 10**6
n = int(input())
nums = [int(v) for v in input().split()]
other_nums = Counter(nums)
mysum = sum(nums)
result = []
for i, val in enumerate(nums, 1):
    mysum -= val
    other_nums[val] -= 1
    if not mysum % 2 and mysum / 2 <= MAX and other_nums.get(mysum/2, 0) > 0:
        result.append(str(i))

    other_nums[val] += 1
    mysum += val

print(len(result))
print(' '.join(result))


from collections import Counter
siz = int(input()); lt = list(map(int,input().split()))
c,s,ans = Counter(lt),sum(lt),[]
for x in range(siz):
    a = s - lt[x]
    if a%2 == 0:
        t = a/2
        if t == lt[x]:
            if c[t] > 2: ans.append(x+1)
        else:
            if t in c : ans.append(x+1)
print(len(ans))
print(*ans)


from collections import Counter
siz = int(input()); lt = list(map(int,input().split()))
c,s,ans = Counter(lt),sum(lt),[]
for x in range(siz):
    a = s - lt[x]
    if a%2 == 0:
        t = a/2
        if t == lt[x]:
            if c[t] >= 2: ans.append(x+1)
        else:
            if t in c : ans.append(x+1)
print(len(ans))
print(*ans)


n=int(input())
a=[int(x) for x in input().split()]
c=0
place=[-1 for i in range (n)]

def good(a):
	x=False
	if 2*max(a)==sum(a):
		x=True
	return x
for i in range (n):
	d=a[i]
	a[i]=0
	if good(a):
		place[c]=i+1
		c+=1
	a[i]=d
print(c)
for i in range (n):
	if place[i]!=-1:
		print(place[i],end=" ")


n=int(input())
a=[0 for i in range (n)]
a=input().split()
for i in range (n):
	a[i]=int(a[i])
c=0
place=[-1 for i in range (n)]

def good(a):
	x=False
	if 2*max(a)==sum(a):
		x=True
	return x
for i in range (n):
	d=a[i]
	a[i]=0
	if good(a):
		place[c]=i+1
		c+=1
	a[i]=d
print(c)
for i in range (n):
	if place[i]!=-1:
		print(place[i],end=" ")


n=int(input())
a=[int(x) for x in input().split()]
summ=sum(a)
ans=[]
q=sorted(a)
maks=q[-1]
maks2=q[-2]
for i in range (n):
	cout=maks
	if a[i]==maks:
		cout=maks2
	if summ-a[i]==2*cout:
		ans.append(i+1)
print(len(ans))
print(*ans)


# -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 19:35:21 2020

@author: Dark Soul
"""

n=input('')
n=int(n)
strrr = list(map(int, input().split()))
copy_str=strrr
strr=sorted(strrr,reverse=True)
index=[]
maxx=strr[0]
cnt1=0
for i in range(len(strr)):
    if strr[i]==maxx:
        cnt1=cnt1+1
    if cnt1>2:
        break
if cnt1>2:
    index=[]
elif cnt1==2:
    print('Hi')
    if sum(strr)==3*maxx:
        my_str=copy_str
        index.append(my_str.index(maxx)+1)
        del(my_str[my_str.index(maxx)])
        index.append(my_str.index(maxx)+2)
    else:
        index=[]
else:

    if strr.count(strr[1])==1:
        if sum(strr)==2*strr[1]+maxx:
            index.append(copy_str.index(maxx)+1)
    if sum(strr)>2*maxx:
        j=1
        while j<len(strr):
            cnt=strr.count(strr[j])
            if sum(strr)==2*maxx+strr[j]:

                my_str=copy_str

                for k in range(cnt):

                    ind=my_str.index(strr[j])+k+1
                    index.append(ind)
                    del(my_str[ind-k-1])
            if sum(strr)>2*maxx+strr[j]:
                break

            j=j+cnt

y=len(index)
print(len(index))
if n==0:
    print('')
else:
    print(*index)


# -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 19:35:21 2020

@author: Dark Soul
"""

n=input('')
n=int(n)
strrr = list(map(int, input().split()))
copy_str=strrr
strr=sorted(strrr,reverse=True)
index=[]
maxx=strr[0]
cnt1=0
for i in range(len(strr)):
    if strr[i]==maxx:
        cnt1=cnt1+1
    if cnt1>2:
        break
if cnt1>2:
    index=[]
elif cnt1==2:
    print('Hi')
    if sum(strr)==3*maxx:
        my_str=copy_str
        index.append(my_str.index(maxx)+1)
        del(my_str[my_str.index(maxx)])
        index.append(my_str.index(maxx)+2)
    else:
        index=[]
else:

    if strr.count(strr[1])==1:
        if sum(strr)==2*strr[1]+maxx:
            index.append(copy_str.index(maxx)+1)
    if sum(strr)>=2*maxx:
        j=1
        while j<len(strr):
            cnt=strr.count(strr[j])
            if sum(strr)==2*maxx+strr[j]:

                my_str=copy_str

                for k in range(cnt):

                    ind=my_str.index(strr[j])+k+1
                    index.append(ind)
                    del(my_str[ind-k-1])

            j=j+cnt

y=len(index)
print(len(index))
if n==0:
    print('')
else:
    print(*index)


# -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 19:35:21 2020

@author: Dark Soul
"""

n=input('')
n=int(n)
strrr = list(map(int, input().split()))
copy_str=strrr
strr=sorted(strrr,reverse=True)
index=[]
maxx=strr[0]
cnt1=strr.count(maxx)
if cnt1>2:
    index=[]
elif cnt1==2:
    if sum(strr)==3*maxx:
        my_str=copy_str
        index.append(my_str.index(maxx)+1)
        del(my_str[my_str.index(maxx)])
        index.append(my_str.index(maxx)+2)
    else:
        index=[]
else:
    if strr.count(strr[1])==1:
        if sum(strr)==2*strr[1]+maxx:
            index.append(copy_str.index(maxx)+1)
    j=1
    while j<len(strr):
        cnt=strr.count(strr[j])
        if sum(strr)==2*maxx+strr[j]:

            my_str=copy_str

            for k in range(cnt):

                ind=my_str.index(strr[j])+k+1
                index.append(ind)
                del(my_str[ind-k-1])

        j=j+cnt

y=len(index)
print(len(index))
if n==0:
    print('')
else:
    print(*index)


# -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 19:35:21 2020

@author: Dark Soul
"""

n=input('')
n=int(n)
strrr = list(map(int, input().split()))
copy_str=strrr
strr=sorted(strrr,reverse=True)
index=[]
maxx=strr[0]
cnt1=0
for i in range(len(strr)):
    if strr[i]==maxx:
        cnt1=cnt1+1
    if cnt1>2:
        break
if cnt1>2:
    index=[]
elif cnt1==2:
    print('Hi')
    if sum(strr)==3*maxx:
        my_str=copy_str
        index.append(my_str.index(maxx)+1)
        del(my_str[my_str.index(maxx)])
        index.append(my_str.index(maxx)+2)
    else:
        index=[]
else:
    if strr.count(strr[1])==1:
        if sum(strr)==2*strr[1]+maxx:
            index.append(copy_str.index(maxx)+1)
    j=1
    while j<len(strr):
        cnt=strr.count(strr[j])
        if sum(strr)==2*maxx+strr[j]:

            my_str=copy_str

            for k in range(cnt):

                ind=my_str.index(strr[j])+k+1
                index.append(ind)
                del(my_str[ind-k-1])

        j=j+cnt

y=len(index)
print(len(index))
if n==0:
    print('')
else:
    print(*index)


# -*- coding: utf-8 -*-
"""
Created on Fri Jun 26 05:17:52 2020

@author: Dark Soul
"""

n=input('')
n=int(n)
strrr = list(map(int, input().split()))
copy_str=strrr
strr=sorted(strrr,reverse=True)
index=[]
maxx=strr[0]
cnt1=strr.count(maxx)
if cnt1>2:
    if cnt1==len(strr):
        index=list(range(1,len(strr)+1,1))
elif cnt1==2:
    if len(strr)==3:
        for i in range(3):
            if copy_str[i]!=maxx:
                index.append(i+1)
    elif sum(strr)==3*maxx:
        my_str=copy_str
        index.append(my_str.index(maxx)+1)
        del(my_str[my_str.index(maxx)])
        index.append(my_str.index(maxx)+2)
    else:
        index=[]
else:
    if strr.count(strr[1])==1 or (len(strr)==3 and strr.count(strr[1])==2):
        if (sum(strr)==2*strr[1]+maxx):
            index.append(copy_str.index(maxx)+1)
    if sum(strr)>2*maxx:
        j=1
        while j<len(strr):
            cnt=strr.count(strr[j])
            if sum(strr)==2*maxx+strr[j]:
                if cnt==len(strr)-1:
                    i=copy_str.index(maxx)+1
                    index=list(range(1,len(strr)+1,1))
                    del(index[i-1])
                    break

                my_str=copy_str

                for k in range(cnt):

                    ind=my_str.index(strr[j])+k+1
                    index.append(ind)
                    del(my_str[ind-k-1])
            if sum(strr)>2*maxx+strr[j]:
                break

            j=j+cnt

y=len(index)
print(len(index))
if n==0:
    print('')
else:
    print(*index)


# -*- coding: utf-8 -*-
"""
Created on Fri Jun 26 05:17:52 2020

@author: Dark Soul
"""

n=input('')
n=int(n)
strrr = list(map(int, input().split()))
copy_str=strrr
strr=sorted(strrr,reverse=True)
index=[]
maxx=strr[0]
cnt1=0
for i in range(len(strr)):
    if strr[i]==maxx:
        cnt1=cnt1+1
    if cnt1>2:
        break
if cnt1>2:
    index=[]
elif cnt1==2:

    if sum(strr)==3*maxx:
        my_str=copy_str
        index.append(my_str.index(maxx)+1)
        del(my_str[my_str.index(maxx)])
        index.append(my_str.index(maxx)+2)
    else:
        index=[]
else:

    if strr.count(strr[1])==1:
        if sum(strr)==2*strr[1]+maxx:
            index.append(copy_str.index(maxx)+1)
    if sum(strr)>2*maxx:
        j=1
        while j<len(strr):
            cnt=strr.count(strr[j])
            if sum(strr)==2*maxx+strr[j]:
                if cnt==len(strr)-1:
                    i=copy_str.index(maxx)+1
                    index=list(range(1,len(strr)+1,1))
                    del(index[i-1])
                    break

                my_str=copy_str

                for k in range(cnt):

                    ind=my_str.index(strr[j])+k+1
                    index.append(ind)
                    del(my_str[ind-k-1])
            if sum(strr)>2*maxx+strr[j]:
                break

            j=j+cnt

y=len(index)
print(len(index))
if n==0:
    print('')
else:
    print(*index)