#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 100;

vector<int> gr[N];
int intm[N], outtm[N];

int par[N][2];

bool isDrawPossible(int v, int & tm) {
    intm[v] = ++tm;
    bool ret = false;
    for (auto u : gr[v]) {
        if (intm[u]) {
            ret |= intm[u] < intm[v] and not outtm[u];
        } else {
            ret |= isDrawPossible(u, tm);
        }
    }
    outtm[v] = ++tm;
    return ret;
}

void go(int v, int odd, int fr) {
    int nxtodd = odd xor 1;
    for (auto u : gr[v]) {
        if (par[u][nxtodd]) {
            continue;
        }

        par[u][nxtodd] = v;
        go(u, nxtodd, v);
    }
}

int main()
{
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            gr[i].push_back(x);
        }
    }
    int s;
    cin >> s;
    int tm = 0;
    bool drawPossible = isDrawPossible(s, tm);

    go(s, 0, 0);

    for (int i = 1; i <= n; ++i) {
        if (par[i][1] and gr[i].empty()) {
            vector<int> ans;
            int lst = i;
            int odd = 1;
            while (lst != 0) {
                ans.push_back(lst);
                lst = par[lst][odd];
                odd ^= 1;
            }
            reverse(ans.begin(), ans.end());
            cout << "Win\n";
            for (int i = 0; i < (int)ans.size(); ++i) {
                if (i) cout << ' ';
                cout << ans[i];
            }
            cout << '\n';
            return 0;
        }
    }

    if (drawPossible) {
        cout << "Draw\n";
        return 0;
    }

    cout << "Lose\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 100;

vector<int> gr[N];
int intm[N], outtm[N];

int par[N][2];

bool isDrawPossible(int v, int & tm) {
    intm[v] = ++tm;
    bool ret = false;
    for (auto u : gr[v]) {
        if (intm[u]) {
            ret |= intm[u] < intm[v] and not outtm[u];
        } else {
            ret |= isDrawPossible(u, tm);
        }
    }
    outtm[v] = ++tm;
    return ret;
}

pair<int, int> go(int v, int odd, int fr) {
    if (gr[v].empty() and odd) {
        return {v, odd};
    }
    int nxtodd = odd xor 1;
    pair<int, int> lst = {0, 0};
    for (auto u : gr[v]) {
        if (par[u][nxtodd]) {
            continue;
        }

        par[u][nxtodd] = v;
        auto lst2 = go(u, nxtodd, v);
        if (lst2.first) {
            lst = lst2;
        }
    }
    return lst;
}

int main()
{
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            gr[i].push_back(x);
        }
    }
    int s;
    cin >> s;
    int tm = 0;
    bool drawPossible = isDrawPossible(s, tm);

    auto lst = go(s, 0, 0);

    if (lst.first) {
        vector<int> ans;
        while (lst.first != 0) {
            ans.push_back(lst.first);
            lst.first = par[lst.first][lst.second];
            lst.second ^= 1;
        }
        reverse(ans.begin(), ans.end());
        cout << "Win\n";
        for (int i = 0; i < (int)ans.size(); ++i) {
            if (i) cout << ' ';
            cout << ans[i];
        }
        cout << '\n';
        return 0;
    }

    if (drawPossible) {
        cout << "Draw\n";
        return 0;
    }

    cout << "Lose\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 100;

vector<int> gr[N];
int intm[N], outtm[N];

vector<int> revGr[N];
int par[N][2];

bool isDrawPossible(int v, int & tm) {
    intm[v] = ++tm;
    bool ret = false;
    for (auto u : gr[v]) {
        if (intm[u]) {
            if (intm[u] < intm[v] and not outtm[u]) {
                ret = true;
            }
        } else {
            ret |= isDrawPossible(u, tm);
        }
    }
    outtm[v] = ++tm;
    return ret;
}

void reverseGraph(int n) {
    for (int i = 1; i <= n; ++i) {
        for (auto v : gr[i]) {
            revGr[v].push_back(i);
        }
    }
}

void go(int v, int odd) {
    int nxtodd = odd xor 1;
    for (auto u : revGr[v]) {
        if (par[u][nxtodd]) continue;

        par[u][nxtodd] = v;
        go(u, nxtodd);
    }
}

void run(int n) {
    vector<int> starts;
    for (int i = 1; i <= n; ++i) {
        if (gr[i].empty()) {
            starts.push_back(i);
        }
    }
    for (auto start : starts) {
        go(start, 0);
    }
}

int main()
{
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            gr[i].push_back(x);
        }
    }
    int s;
    cin >> s;
    int tm = 0;
    bool drawPossible = isDrawPossible(s, tm);

    reverseGraph(n);
    run(n);

    if (par[s][1]) {
        vector<int> ans;
        ans.push_back(s);
        int nxt = s;
        int odd = 1;
        do {
            nxt = par[nxt][odd];
            ans.push_back(nxt);
            odd = odd xor 1;
        } while (par[nxt][odd]);
        cout << "Win\n";
        for (int i = 0; i < (int)ans.size(); ++i) {
            if (i) cout << ' ';
            cout << ans[i];
        }
        cout << '\n';
        return 0;
    }

    if (drawPossible) {
        cout << "Draw\n";
        return 0;
    }

    cout << "Lose\n";
    return 0;
}


#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <bitset>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define PI 3.1415926535897932384626433832795
#define inf 0x3f3f3f3f
#define MAXN 100005
#define MAXM 10005
using namespace std;
typedef long long ll;
const double EPS=1e-6;

vector <int>G[MAXN];
vector<int>ans;
int book[MAXN][2];
int vis[MAXN];

bool dfs(int u,int step){

//	cout<<u<<' '<<step<<' '<<G[u].size()<<endl;
	if(G[u].size()==0)
		if(step%2)
			return 1;

	int flag=0;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(book[v][step%2]==0){
			book[v][step%2]=1;
			ans.push_back(v);
			if(flag)return 1;
			else
			{
				flag=dfs(v,step+1);
				if(flag)
					return flag;
			}
			ans.pop_back();
		}
	}

	return flag;
}

bool isloop(int x){
	vis[x]=1;
	int flag=0;
	for(int i=0;i<G[x].size();i++){
		if(vis[G[x][i]]==1)
			flag=1;
		else if(vis[G[x][i]]==0)
			flag=isloop(G[x][i]);

		if(flag)
			return true;
	}
	vis[x]=2;
	return false;
}

int main()
{
	//ios::sync_with_stdio(false);
	int n,m;
	int c,s,v;
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&c);
		for(j=1;j<=c;j++){
			scanf("%d",&v);
			G[i].push_back(v);
		}
	}

	scanf("%d",&s);
	int flag=isloop(s);

	ans.push_back(s);
	int isWin=dfs(s,0);

	if(isWin){
		printf("Win\n");
		for(i=0;i<ans.size();i++)
		{
			printf("%d ",ans[i]);
		}
	}else
	{
		if(flag==1)
			printf("Draw\n");
		else
			printf("Lose\n");
	}
	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <bitset>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define PI 3.1415926535897932384626433832795
#define inf 0x3f3f3f3f
#define MAXN 100005
#define MAXM 10005
using namespace std;
typedef long long ll;
const double EPS=1e-6;

vector <int>G[MAXN];
vector<int>ans;
int book[MAXN][2];
int vis[MAXN];

bool dfs(int u,int step){

//	cout<<u<<' '<<step<<' '<<G[u].size()<<endl;
	if(G[u].size()==0)
		if(step%2)
			return 1;

	int flag=0;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(book[v][step%2]==0){
			book[v][step%2]=1;
			ans.push_back(v);
			if(flag)return 1;
			else
			{
				flag=dfs(v,step+1);
				return flag;
			}
			ans.pop_back();
		}
	}

	return flag;
}

bool isloop(int x){
	vis[x]=1;
	for(int i=0;i<G[x].size();i++){
		if(vis[G[x][i]]==1)
			return 1;
		else if(vis[G[x][i]]==0)
			return isloop(G[x][i]);
	}
	vis[x]=2;
	return false;
}

int main()
{
	//ios::sync_with_stdio(false);
	int n,m;
	int c,s,v;
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&c);
		for(j=1;j<=c;j++){
			scanf("%d",&v);
			G[i].push_back(v);
		}
	}

	scanf("%d",&s);
	int flag=isloop(s);

	ans.push_back(s);
	int isWin=dfs(s,0);

	if(isWin){
		printf("Win\n");
		for(i=0;i<ans.size();i++)
		{
			printf("%d ",ans[i]);
		}
	}else
	{
		if(flag==1)
			printf("Draw\n");
		else
			printf("Lose\n");
	}
	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <bitset>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define PI 3.1415926535897932384626433832795
#define inf 0x3f3f3f3f
#define MAXN 1005
#define MAXM 10005
using namespace std;
typedef long long ll;
const double EPS=1e-6;

vector <int>G[MAXN];
vector<int>ans;
int book[MAXN][2];
int vis[MAXN];

bool dfs(int u,int step){

//	cout<<u<<' '<<step<<' '<<G[u].size()<<endl;
	if(G[u].size()==0)
		if(step%2)
			return 1;

	int flag=0;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(book[v][step%2]==0){
			book[v][step%2]=1;
			ans.push_back(v);
			if(flag)return 1;
			else
			{
				flag=dfs(v,step+1);
				return flag;
			}
			ans.pop_back();
		}
	}

	return flag;
}

bool isloop(int x){
	vis[x]=1;
	for(int i=0;i<G[x].size();i++){
		if(vis[G[x][i]]==1)
			return 1;
		else if(vis[G[x][i]]==0)
			return isloop(G[x][i]);
	}
	vis[x]=2;
	return false;
}

int main()
{
	//ios::sync_with_stdio(false);
	int n,m;
	int c,s,v;
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&c);
		for(j=1;j<=c;j++){
			scanf("%d",&v);
			G[i].push_back(v);
		}
	}

	scanf("%d",&s);
	int flag=isloop(s);

	ans.push_back(s);
	int isWin=dfs(s,0);

	if(isWin){
		printf("Win\n");
		for(i=0;i<ans.size();i++)
		{
			printf("%d ",ans[i]);
		}
	}else
	{
		if(flag==1)
			printf("Draw\n");
		else
			printf("Lose\n");
	}
	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <bitset>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define PI 3.1415926535897932384626433832795
#define inf 0x3f3f3f3f
#define MAXN 100005
#define MAXM 10005
using namespace std;
typedef long long ll;
const double EPS=1e-6;

vector <int>G[MAXN];
vector<int>ans;
int book[MAXN][2];
int vis[MAXN];

bool dfs(int u,int step){

//	cout<<u<<' '<<step<<' '<<G[u].size()<<endl;
	if(G[u].size()==0)
		if(step%2)
			return 1;

	int flag=0;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(book[v][step%2]==0){
			book[v][step%2]=1;
			ans.push_back(v);
			if(flag)return 1;
			else
			{
				flag=dfs(v,step+1);
				if(flag)
					return flag;
			}
			ans.pop_back();
		}
	}

	return flag;
}

bool isloop(int x){
	vis[x]=1;
	for(int i=0;i<G[x].size();i++){
		if(vis[G[x][i]]==1)
			return 1;
		else if(vis[G[x][i]]==0)
			return isloop(G[x][i]);
	}
	vis[x]=2;
	return false;
}

int main()
{
	//ios::sync_with_stdio(false);
	int n,m;
	int c,s,v;
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&c);
		for(j=1;j<=c;j++){
			scanf("%d",&v);
			G[i].push_back(v);
		}
	}

	scanf("%d",&s);
	int flag=isloop(s);

	ans.push_back(s);
	int isWin=dfs(s,0);

	if(isWin){
		printf("Win\n");
		for(i=0;i<ans.size();i++)
		{
			printf("%d ",ans[i]);
		}
	}else
	{
		if(flag==1)
			printf("Draw\n");
		else
			printf("Lose\n");
	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define eps 1e-6

using namespace std;

bool DRAW = false, WIN = false;
vector<int> save[200005];
int rec[200005];
int path[200005];
int fp = 0;

void dfs(int now, int cnt)
{
	if (save[now].size())
	{
		for (int i : save[now])
		{
			if (rec[i])
			{
				DRAW = true;
				continue;
			}
			rec[i] = 1;
			dfs(i, cnt + 1);
			if (WIN)
			{
				path[fp++] = now;
				return;
			}
			rec[i] = 0;
		}
	}
	else
	{
		if (cnt % 2 == 0)
		{
			WIN = true;
			path[fp++] = now;
			return;
		}
		else
		{
			return;
		}
	}
}

int main(void)
{
	int n, m;
	cin >> n >> m;
	int x, tmp;
	for (size_t i = 1; i <= n; i++)
	{
		cin >> x;
		for (size_t j = 0; j < x; j++)
		{
			cin >> tmp;
			save[i].push_back(tmp);
		}
	}
	int s;
	cin >> s;
	rec[s] = 1;
	dfs(s, 1);
	int need = 0;
	if (WIN)
	{
		cout << "Win" << endl;
		for (int i = fp - 1; i >= 0; i--)
		{
			if (need)
				putchar(' ');
			cout << path[i];
			need = 1;
		}
	}
	else if(DRAW)
	{
		cout << "Draw";
	}
	else
	{
		cout << "Lose";
	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define eps 1e-6

using namespace std;

bool DRAW = false, WIN = false;
vector<int> save[200005];
int rec[200005];
int path[200005];
int fp = 0;

void dfs(int now, int cnt)
{
	if (save[now].size())
	{
		for (int i : save[now])
		{
			if (rec[i])
			{
				DRAW = true;
				continue;
			}
			rec[i] = 1;
			dfs(i, cnt + 1);
			if (WIN)
			{
				path[fp++] = now;
				return;
			}
			rec[i] = 0;
		}
	}
	else
	{
		if (cnt % 2 == 0)
		{
			WIN = true;
			path[fp++] = now;
		}
		else
		{
			return;
		}
	}
}

int main(void)
{
	int n, m;
	cin >> n >> m;
	int x, tmp;
	for (size_t i = 1; i <= n; i++)
	{
		cin >> x;
		for (size_t j = 0; j < x; j++)
		{
			cin >> tmp;
			save[i].push_back(tmp);
		}
	}
	int s;
	cin >> s;
	rec[s] = 1;
	dfs(s, 1);
	int need = 0;
	if (WIN)
	{
		cout << "Win" << endl;
		for (int i = fp - 1; i >= 0; i--)
		{
			if (need)
				putchar(' ');
			cout << path[i];
			need = 1;
		}
	}
	else if(DRAW)
	{
		cout << "Draw";
	}
	else
	{
		cout << "Lose";
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool DRAW = false, WIN = false;
vector<int> save[200005];
int rec[200005][2];
int path[200005];
int ins[200005];
int fp = 0;

void dfs(int now, int cnt)
{
	if (save[now].size())
	{
		for (int i : save[now])
		{
			if (!rec[i][(cnt + 1) % 2])
			{
				rec[i][(cnt + 1) % 2] = 1;
				dfs(i, cnt + 1);
				if (WIN)
				{
					path[fp++] = now;
					return;
				}
			}
		}
	}
	else
	{
		if (cnt % 2 == 0)
		{
			WIN = true;
			path[fp++] = now;
			return;
		}
		else
		{
			return;
		}
	}
}

void dfss(int now)
{
	for (int i : save[now])
	{
		if (ins[i])
		{
			DRAW = true;
			return;
		}
		ins[i] = 1;
		dfss(i);
		if (DRAW)
			return;
		ins[i] = 0;
	}
}

int main(void)
{
	int n, m;
	cin >> n >> m;
	int x, tmp;
	for (size_t i = 1; i <= n; i++)
	{
		cin >> x;
		for (size_t j = 0; j < x; j++)
		{
			cin >> tmp;
			save[i].push_back(tmp);
		}
	}
	int s;
	cin >> s;
	rec[s][1] = 1;
	dfs(s, 1);
	if (WIN)
	{
		int need = 0;
		cout << "Win" << endl;
		for (int i = fp - 1; i >= 0; i--)
		{
			if (need)
				putchar(' ');
			cout << path[i];
			need = 1;
		}
	}
	else
	{
		dfss(s);
		if (DRAW)
			cout << "Draw";
		else
			cout << "Lose";
	}
	return 0;
}


#include <bits/stdc++.h>
#define ull unsigned long long
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pp pair<int,int>
#define rep(ii,a,b) for(int ii=a;ii<=b;ii++)
#define per(ii,a,b) for(int ii=a;ii>=b;ii--)
using namespace std;
const int maxn=4e5+10;
const int maxm=1e6+10;
const int INF=0x3f3f3f3f;
int casn,n,m,k;
int head[maxn],nume;
struct node {int to,next;} e[maxm];
void add(int a,int b) {
	e[++nume]=(node) {b,head[a]};
	head[a]=nume;
}
int flag=0,draw=0;
int top,ans[maxn],s,vis[maxn];
void dfs(int now) {
	int cnt=0;
	vis[now]=1;
	ans[++top]=now;
	for(int i=head[now]; i; i=e[i].next) {
		int to=e[i].to;
		if(flag) return;
		if(!vis[to]) dfs(to);
		else draw=1;
		cnt++;
	}
	if(now>n&&cnt==0) {
		flag=1;
	}
	if(flag==0) {
		while(ans[top]!=now) top--;
		top--;
	}
}
int main() {
//#define test
#ifdef test
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	IO;
	cin>>n>>m;
	rep(i,1,n) {
		int a,b;
		cin>>a;
		while(a--) {
			cin>>b;
			add(i,b+n);
			add(i+n,b);
		}
	}
	cin>>s;
	dfs(s);
	if(flag) {
		cout<<"Win\n";
		for(int i=1; i<=top; i++) {
			cout<<(ans[i]>n? ans[i]-n:ans[i])<<' ';
		}
		cout<<endl;
	} else if(draw) cout<<"Draw\n";
	else cout<<"Lose\n";

#ifdef test
	fclose(stdin);
	fclose(stdout);
	system("out.txt");
#endif
	return 0;
}


#include <bits/stdc++.h>
#define ull unsigned long long
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pp pair<int,int>
#define rep(ii,a,b) for(int ii=a;ii<=b;ii++)
#define per(ii,a,b) for(int ii=a;ii>=b;ii--)
using namespace std;
const int maxn=4e5+10;
const int maxm=1e6+10;
const int INF=0x3f3f3f3f;
int casn,n,m,k;
int head[maxn],nume;
struct node {int to,next;} e[maxm];
void add(int a,int b) {
	e[++nume]=(node) {b,head[a]};
	head[a]=nume;
}
int flag=0,draw=0;
int top,ans[maxn],s,vis[maxn];
void dfs(int now) {
	int cnt=0;
	vis[now]=1;
	ans[++top]=now;
	for(int i=head[now]; i; i=e[i].next) {
		int to=e[i].to;
		if(flag) return;
		if(!vis[to]) dfs(to);
		else draw=1;
		cnt++;
	}
	if(now>n&&cnt==0) {
		flag=1;
	}
	if(flag==0){
		vis[now]=0;
		top--;
	}
}
int main() {
//#define test
#ifdef test
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	IO;
	cin>>n>>m;
	rep(i,1,n) {
		int a,b;
		cin>>a;
		while(a--) {
			cin>>b;
			add(i,b+n);
			add(i+n,b);
		}
	}
	cin>>s;
	dfs(s);
	if(flag) {
		cout<<"Win\n";
		for(int i=1; i<=top; i++) {
			cout<<(ans[i]>n? ans[i]-n:ans[i])<<' ';
		}
		cout<<endl;
	} else if(draw) cout<<"Draw\n";
	else cout<<"Lose\n";

#ifdef test
	fclose(stdin);
	fclose(stdout);
	system("out.txt");
#endif
	return 0;
}


i=input
n=int(input())
s=i().split()
s+='0'
f,t,l=[0,0,0]

for x in range(1,len(s)):
	if int(s[x])<int(s[x-1]):
		if l<(x-f):
			l=x-f
			f=x
print(l)


i=input
n=int(input())
s=i().split()
min=1000000000
mini=0
max=0
maxi=0
for j in range(len(s)):
	x=int(s[j])
	if x>max:
		max=x
		maxi=j
for j in range(len(s)):
	x=int(s[j])
	if x<min and j<=maxi:
		min=x
		mini=j
print(maxi-mini+1)


i=input
n=int(input())
s=i().split()
s+='0'
f,t,l=[0,0,0]
if n==1000:
	print(s)
for x in range(1,len(s)):
	if int(s[x])<int(s[x-1]):
		if l<(x-f):
			l=x-f
			f=x
print(l)


i=input
n=int(input())
s=i().split()
s+='0'
f,t,l=[0,0,0]
for x in range(1,len(s)):
	if int(s[x])<int(s[x-1]):
		if l<(x-f):
			l=x-f
			if l==463:
				print(x)
				print(f)
			f=x
print(l)


i=input
n=int(input())
s=i().split()
min=1000000000
mini=0
max=0
maxi=0
for j in range(len(s)):
	x=int(s[j])
	if x>max:
		max=x
		maxi=j
for j in range(len(s)):
	x=int(s[j])
	if x<=min and j<=maxi:
		min=x
		mini=j
print(maxi-mini+1)


i=input
n=int(input())
s=i().split()
s+='0'
f,t,l=[0,0,0]
for x in range(1,len(s)):
	if int(s[x])<int(s[x-1]):
		if l<(x-f):
			l=x-f
			f=x
print(l)


i=input
n=int(input())
s=i().split()
s+='0'
f,t,l=[0,0,0]
print(s)
for x in range(1,len(s)):
	if int(s[x])<int(s[x-1]):
		if l<(x-f):
			l=x-f
			f=x
print(l)


i=input
n=int(input())
s=i().split()
min=1000000000
mini=0
max=0
maxi=0
for j in range(len(s)):
	x=int(s[j])
	if x<min:
		min=x
		mini=j
	if x>max:
		max=x
		maxi=j
print(maxi-mini+1)


i=input
n=int(input())
s=i().split()
s+='0'
f,t,l=[0,0,0]
if n='1000':
	print(s)
for x in range(1,len(s)):
	if int(s[x])<int(s[x-1]):
		if l<(x-f):
			l=x-f
			f=x
print(l)


x=int(input())
y=input()
y=y.split()
c=1
cc=[]
f=0
k=0
if x==1:
	print('1')
else:
	for i in range(len(y)-1):
		if int(y[i])<=int(y[i+1]):
			c=c+1
			f=1
			k=0
		else:
			f=0
			c=1
			k=1

		cc.append(c)
	#print (cc)
	if len(cc)==0 and k==1:
		print(0)
	else:
		cc.sort()
		print (cc[len(cc)-1])


x=int(input())
y=input()
y=y.split()
c=1
cc=[]
f=0
for i in range(len(y)-1):
	if y[i]<=y[i+1]:
		c=c+1
		f=1
	else:
		f=0
		c=1
	if c>=1:
		cc.append(c)
if len(cc)==0:
	print(0)
else:
	cc.sort()
	print (cc[len(cc)-1])


x=int(input())
y=input()
y=y.split()
c=1
cc=[]
f=0
k=0
for i in range(len(y)-1):

	if int(y[i])<=int(y[i+1]):

		c=c+1
		f=1
	else:
		if c>1:

			cc.append(c)
		f=0
		c=1
		k=1
if k==0:
	print(c)
elif len(cc)==0 and k==1:
	print(0)
else:
	cc.sort()
	print (cc[len(cc)-1])


x=int(input())
y=input()
y=y.split()
c=1
cc=[]
f=0
k=0
for i in range(len(y)-1):

	if int(y[i])<=int(y[i+1]):

		c=c+1
		f=1
	else:
		if c>1:
			print(c,y[i],y[i+1])
			cc.append(c)
		f=0
		c=1
		k=1
print(cc)
if k==0:
	print(c)
elif len(cc)==0 and k==1:
	print(0)
else:
	cc.sort()
	print (cc[len(cc)-1])


x=int(input())
y=input()
y=y.split()
c=1
cc=[]
f=0
k=0
for i in range(len(y)-1):
	if int(y[i])<=int(y[i+1]):
		c=c+1
		f=1
		k=0
	else:
		f=0
		c=1
		k=1
	if k==0:
		cc.append(c)
#print (cc)
if len(cc)==0 and k==1:
	print(0)
else:
	cc.sort()
	print (cc[len(cc)-1])


x=int(input())
y=input()
y=y.split()
c=1
cc=[]
f=0
k=0
if x==1:
	print(y[0])
else:
	for i in range(len(y)-1):
		if int(y[i])<=int(y[i+1]):
			c=c+1
			f=1
			k=0
		else:
			f=0
			c=1
			k=1

		cc.append(c)
	#print (cc)
	if len(cc)==0 and k==1:
		print(0)
	else:
		cc.sort()
		print (cc[len(cc)-1])


x=int(input())
y=input()
y=y.split()
c=1
cc=[]
f=0
k=0
if x==1:
	print(y[0])
else:
	for i in range(len(y)-1):
		if int(y[i])<=int(y[i+1]):
			c=c+1
			f=1
			k=0
		else:
			f=0
			c=1
			k=1
		if k==0:
			cc.append(c)
#print (cc)
	if len(cc)==0 and k==1:
		print(0)
	else:
		cc.sort()
		print (cc[len(cc)-1])


a=int(input())
c=0
b=input().split()
c=[]
for i in range(len(b)):
	b[i]=int(b[i])
counter=1
i=0
while(True):
	if(i==len(b)-1):
		break
	else:
		if(b[i+1]>=b[i]):
			counter=counter+1
			i=i+1
		else:
			c.append(counter)
			i=i+1
			counter=1
print(max(c))


a=int(input())
b=input().split()
c=[1]
for i in range(len(b)):
	b[i]=int(b[i])
counter=1
i=0
while(True):
	if(i==len(b)-1):
		break
	else:
		if(b[i+1]>=b[i]):
			counter=counter+1
			i=i+1
		else:
			c.append(counter)
			i=i+1
			counter=1
print(max(c))


a=int(input())
b=input().split()
c=[]
for i in range(len(b)):
	b[i]=int(b[i])
counter=1
i=0
while(True):
	if(i==len(b)-1):
		break
	else:
		if(b[i+1]>=b[i]):
			counter=counter+1
			i=i+1
			if(i==len(b)-1):
				c.append(counter)
		else:
			c.append(counter)
			i=i+1
			counter=1
print(max(c))
input()


a=int(input())
b=input().split()
c=[]
for i in range(len(b)):
	b[i]=int(b[i])
counter=1
i=0
while(True):
	if(i==len(b)-1):
		break
	else:
		if(b[i+1]>=b[i]):
			counter=counter+1
			i=i+1
			if(i==len(b)-1):
				c.append(counter)
		else:
			c.append(counter)
			i=i+1
			counter=1
print(max(c))


a=int(input())
b=input.split()
c=[]
for i in range(len(b)):
	b[i]=int(b[i])
counter=1
i=0
while(True):
	if(i==len(b)-1):
		break
	else:
		if(b[i+1]>=b[i]):
			counter=counter+1
			i=i+1
		else:
			c.append(counter)
			i=i+1
			counter=1
print(max(c))


a=int(input())
b=input().split()
c=[1]
for i in range(len(b)):
	b[i]=int(b[i])
counter=1
i=0
while(True):
	if(i==len(b)-1):
		break
	else:
		if(b[i+1]>=b[i]):
			counter=counter+1
			i=i+1
			if(i==len(b)-1):
				c.append(counter)
		else:
			c.append(counter)
			i=i+1
			counter=1
print(max(c))


a=int(input())
b=input.split()
c=[1]
for i in range(len(b)):
	b[i]=int(b[i])
counter=1
i=0
while(True):
	if(i==len(b)-1):
		break
	else:
		if(b[i+1]>=b[i]):
			counter=counter+1
			i=i+1
		else:
			c.append(counter)
			i=i+1
			counter=1
print(max(c))


a=int(input())
b=input().split()
c=[1]
for i in range(len(b)):
	b[i]=int(b[i])
counter=1
i=0
while(True):
	if(i==len(b)-1):
		break
	else:
		if(b[i+1]>=b[i]):
			counter=counter+1
			i=i+1
			if(i==len(b)-1):
				c.append(counter)
		else:
			c.append(counter)
			i=i+1
			counter=1
print(max(c))
input()


import sys

sys.setrecursionlimit(100000)
n = int(input())
seq = list(map(lambda x: int(x), input().split(" ")))

def LIS(s, i = 0, currentMax = 0, first = True):
    if i == len(s)-1:
        return currentMax
    elif s[i] <= s[i+1]:
        return LIS(s, i + 1, (2 if first else 1 + currentMax), False)
    else:
        return max(currentMax, LIS(s, i + 1))

print(LIS(seq))


n = int(input())
seq = list(map(lambda x: int(x), input().split(" ")))

def LIS(s):
    longest = 0
    current = 1
    for i in range(len(s)):
        if i > 0 and s[i] >= s[i-1]:
            current += 1
            longest = max(current, longest)
        else:
            current = 1
    return longest

print(LIS(seq))


n = int(input())
seq = list(map(lambda x: int(x), input().split(" ")))

def LIS(s, i = 0, currentMax = 1):
    if i == len(s)-1:
        return currentMax
    elif s[i] <= s[i+1]:
        return LIS(s, i + 1, currentMax + 1)
    else:
        return max(currentMax, LIS(s, i + 1))

print(LIS(seq))


n = int(input())
seq = list(map(lambda x: int(x), input().split(" ")))

def LIS(s):
    longest = 0
    current = 1
    for i in range(len(s)):
        if i > 0 and s[i] >= s[i-1]:
            current += 1
            longest = max(current, longest)
        else:
            current = 0
    return longest

print(LIS(seq))


n = int(input())
seq = list(map(lambda x: int(x), input().split(" ")))

def LIS(s, i = 0, currentMax = 0, first = True):
    if i == len(s)-1:
        return currentMax
    elif s[i] <= s[i+1]:
        return LIS(s, i + 1, (2 if first else 1 + currentMax), False)
    else:
        return max(currentMax, LIS(s, i + 1))

print(LIS(seq))


n = int(input())
seq = list(map(lambda x: int(x), input().split(" ")))

def LIS(s):
    longest = 1
    current = 1
    for i in range(len(s)):
        if i > 0 and s[i] >= s[i-1]:
            current += 1
            longest = max(current, longest)
        else:
            current = 1
    return longest

print(LIS(seq))


n = int(input())
seq = list(map(lambda x: int(x), input().split(" ")))

def LIS(s):
    longest = 0
    current = 0
    for i in range(len(s)):
        if i > 0 and s[i] >= s[i-1]:
            if current == 0:
                current = 2
            else:
                current += 1
            longest = max(current, longest)
        else:
            current = 0
    return longest

print(LIS(seq))


y = input()
y = [int(s) for s in input().split()]
z = 0
h = []
for i in range(len(y)-1):
    if y[i] <= y[i+1]:
        z+=1
    else:
        h.append(z)
        z = 0
print(max(h))


y = input()
y = [int(s) for s in input().split()]
z = 0
h = []
for i in range(len(y)):
    if y[i] <= y[i+1]:
        z+=1
    else:
        h.append(z)
        z = 0
print(max(h)+1)


x = input()
y = [int(s) for s in input().split()]
z = 0
h = 0
for i in range(len(y)-1):
    m = i
    while m < len(y) -1 and y[m] <= y[m+1]:
        h+=1
        m+=1
    if h > z:
        z = h
    h = 0
print(z+1)


x = input()
y = [int(s) for s in input().split()]
z = 0
h = 0
for i in range(len(y)-1):
    m = i
    while m < len(y) -1 and y[m] <= y[m+1]:
        h+=1
        m+=1
    if h > z:
        z = h
    h = 0
print(z)


x = input()
y = [int(s) for s in input().split()]
z = 0
h = 0
for i in range(len(y)-1):
    m = 0
    while m < len(y) -1 and y[m] <= y[m+1]:
        h+=1
        m+=1
    if h > z:
        z = h
    h = 0
print(z)


y = input()
y = [int(s) for s in input().split()]
z = 0
h = []
for i in range(len(y)-1):
    if y[i] <= y[i+1]:
        z+=1
    else:
        h.append(z)
        z = 0
h.append(z)
print(max(h)+1)


y = input()
y = [int(s) for s in input().split()]
z = 0
h = []
for i in range(len(y)-1):
    if y[i] <= y[i+1]:
        z+=1
    else:
        h.append(z)
        z = 0
print(max(h)+1)


x = input()
y = input().split()
z = 0
h = 0
for i in range(int(x)-1):
    while int(y[i]) <= int(y[i+1]):
        h+=1
        i+=1
    if h > z:
        z = h
    h = 0
print(z)


n=int(input())
A=list(map(int,input().split()))
B=[0]*n
for i in range(n-1):
    s=1
    for j in range(i,n-1):
        if A[j+1]>=A[j]:
            s+=1
        else:
            B[i]=s
            break
print(max(B))


n=int(input())
A=list(map(int,input().split()))
s=1
B=[]
if n==1:
    print('1')
else:
    for i in range(n-1):
        if A[i]<=A[i+1]:
            s+=1
        else:
            B.append(s)
            s=1
    if len(B)==0:
        print(s)
    else:
        print(max(max(B),s))


n=int(input())
A=list(map(int,input().split()))
s=1
B=[]
if n==1:
    print('1')
else:
    for i in range(n-1):
        if A[i]<=A[i+1]:
            s+=1
        else:
            B.append(s)
            s=1
if len(B)==0:
    print(s)
else:
    print(max(max(B),s))


n=int(input())
A=list(map(int,input().split()))
s=1
t=0
B=[]
if n==1:
    print('1')
else:
    for i in range(n-1):
        if A[i]<=A[i+1]:
            s+=1
        else:
            t=1
            B.append(s)
            s=1
if t==0:
    print(s)
else:
    print(max(B))


n=int(input())
A=list(map(int,input().split()))
B=[]
if n==1:
    print('1')
else:
    c=1
    for i in range(n-1):
        if A[i]<=A[i+1]:
            c+=1
            B.append(c)
        else:
            c=1
    print(max(B))


n=int(input())
A=list(map(int,input().split()))
B=[]
t=1
if n==1:
    print('1')
else:
    for i in range(n-1):
        if A[i]>A[i+1]:
            t=1
            B.append(t)
        else:
            t=t+1
            B.append(t)
    print(max(B))


n=int(input())
A=list(map(int,input().split()))
B=[]
t=1
for i in range(n-1):
    if A[i]>A[i+1]:
        t=1
        B.append(t)
    else:
        t=t+1
        B.append(t)
print(max(B))


n=int(input())
A=list(map(int,input().split()))
B=[]
if n==1:
    print('1')
else:
    c=1
    for i in range(n-1):
        if A[i]<=A[i+1]:
            c+=1
            B.append(c)
        else:
            c=1
            B.append(c)
    print(max(B))


n=int(input())
A=list(map(int,input().split()))
B=[0]*n
if n==1:
    print('1')
else:
    for i in range(n-1):
        s=1
        for j in range(i,n-1):
            if A[j+1]>=A[j]:
                s+=1
                B[i]=s
            else:
                B[i]=s
                break
    print(max(B))


n=int(input())
A=list(map(int,input().split()))
B=[]
if n==1:
    print('1')
else:
    for i in range(n-1):
        if A[i]<=A[i+1]:
            c+=1
            B.append(c)
        else:
            c=1
    print(max(B))


n = int(input())
if n>=1 and n<=100000:
    a = list(map(int, input().split()))
    num = 0
    temp = 0
    l = len(a)
    i = 0
    while i<l:
        if a[i] <= a[i+1]:
            num += 1

        if a[i] > a[i+1]:
            if num != 0:
                temp = num + 1
                num = 0

        if i == l-2:
            if a[i] <= a[i + 1]:
                num += 1
            break

        i += 1

    if temp > num:
        print(temp)
    else:
        print(num)


n = int(input())
if n>=1 and n<=100000:
    a = list(map(int, input().split()))
    i = len(a)
    check = 1
    if i==n:
        for p in a:
            if p < 1 or p > 1000000000:
                check = 0
                break

        if check == 1:
            num = 0
            temp = 0
            j = 0
            while j<i:
                if a[j] <= a[j+1]:
                    num += 1

                if a[j] > a[j+1]:
                    if num != 0:
                        temp = num + 1
                        num = 0

                if j == i-2:
                    if a[j] <= a[j + 1]:
                        num += 1
                    break

                j += 1

            d = 0
            while d < i-1:
                if a[d] > a[d+1]:
                    hum = 0
                else:
                    hum = 1
                    break
                d += 1
            if hum == 0:
                print("1")

            else:
                if temp > num:
                    print(temp)
                else:
                    print(num)


n = int(input())
if n>=1 and n<=100000:
    a = list(map(int, input().split()))
    i = len(a)
    check = 1
    if i>=1 and i<=n:
        for p in a:
            if p < 1 or p > 1000000000:
                check = 0
                break

        if check == 1:
            num = 0
            temp = 0
            j = 0
            while j<i:
                if a[j] <= a[j+1]:
                    num += 1

                if a[j] > a[j+1]:
                    if num != 0:
                        temp = num + 1
                        num = 0

                if j == i-2:
                    if a[j] <= a[j + 1]:
                        num += 1
                    break

                j += 1

            d = 0
            while d < i-1:
                if a[d] > a[d+1]:
                    hum = 0
                else:
                    hum = 1
                    break
                d += 1
            if hum == 0:
                print("1")

            else:
                if temp > num:
                    print(temp)
                else:
                    print(num)


n = int(input())
if n>=1 and n<=100000:
    a = list(map(int, input().split()))
    i = len(a)
    check = 1
    if i==n:
        for p in a:
            if p < 1 or p > 1000000000:
                check = 0
                break

        if check == 1:
            if i==1:
                print("1")
            else:
                num = 0
                temp = 0
                j = 0
                while j<i:
                    if a[j] <= a[j+1]:
                        num += 1

                    if a[j] > a[j+1]:
                        if num != 0:
                            temp = num + 1
                            num = 0

                    if j == i-2:
                        if a[j] <= a[j + 1]:
                            num += 1
                        break

                    j += 1

                d = 0
                while d < i-1:
                    if a[d] > a[d+1]:
                        decrease = 0
                    else:
                        decrease = 1
                        break
                    d += 1
                if decrease == 0:
                    print("1")

                else:
                    if temp > num:
                        print(temp)
                    else:
                        print(num)


n = int(input())
if n>=1 and n<=100000:
    a = list(map(int, input().split()))
    for p in a:
        if p>=1 and p<=1000000000:
            check = 1
        else:
            check = 0
            break
    if check == 1:
        num = 0
        temp = 0
        l = len(a)
        i = 0
        while i<l:
            if a[i] <= a[i+1]:
                num += 1

            if a[i] > a[i+1]:
                if num != 0:
                    temp = num + 1
                    num = 0

            if i == l-2:
                if a[i] <= a[i + 1]:
                    num += 1
                break

            i += 1

        if temp > num:
            print(temp)
        else:
            print(num)


n = int(input())
if n>=1 and n<=100000:
    a = list(map(int, input().split()))
    day = len(a)
    if day >=1 and day<=n:
        for p in a:
            if p>=1 and p<=1000000000:
                check = 1
            else:
                check = 0
                break
        if check == 1:
            num = 0
            temp = 0
            l = len(a)
            i = 0
            while i<l:
                if a[i] <= a[i+1]:
                    num += 1

                if a[i] > a[i+1]:
                    if num != 0:
                        temp = num + 1
                        num = 0

                if i == l-2:
                    if a[i] <= a[i + 1]:
                        num += 1
                    break

                i += 1

            if temp > num:
                print(temp)
            else:
                print(num)


n = int(input())
if n>=1 and n<=100000:
    a = list(map(int, input().split()))
    i = len(a)
    check = 1
    if i>=1 and i<=n:
        for p in a:
            if p<1 and p>1000000000:
                check = 0
                break

        if check == 1:
            num = 0
            temp = 0
            i = len(a)
            j = 0
            while j<i:
                if a[j] <= a[j+1]:
                    num += 1

                if a[j] > a[j+1]:
                    if num != 0:
                        temp = num + 1
                        num = 0

                if j == i-2:
                    if a[j] <= a[j + 1]:
                        num += 1
                    break

                j += 1

            d = 0
            while d < i-1:
                if a[d] > a[d+1]:
                    hum = 0
                else:
                    hum = 1
                    break
                d += 1
            if hum == 0:
                print("1")

            else:
                if temp > num:
                    print(temp)
                else:
                    print(num)


n = int(input())
if n>=1 and n<=100000:
    a = list(map(int, input().split()))
    i = len(a)
    check = 1
    if i==n:
        for p in a:
            if p < 1 or p > 1000000000:
                check = 0
                break

        if check == 1:
            if i==1:
                print("1")
            else:
                num = 0
                temp = 0
                final = 0
                j = 0
                while j<i:
                    if a[j] <= a[j+1]:
                        num += 1

                    else:
                        if num != 0:
                            temp = num + 1
                            if temp>final:
                                final = temp
                                temp = 0
                            num = 0

                    if j == i-2:
                        if a[j] <= a[j + 1]:
                            num += 1
                        break

                    j += 1

                d = 0
                while d < i-1:
                    if a[d] > a[d+1]:
                        decrease = 0
                    else:
                        decrease = 1
                        break
                    d += 1
                if decrease == 0:
                    print("1")

                else:
                    if final > num:
                        print(final)
                    else:
                        print(num)


n = int(input())
a = list(map(int, input().split(" ")))
i = 0
total = 1
x = []
while (i+1) < n and n > 1:
 if a[i] <= a[i+1] and (i+1) != (n-1):
  total += 1
  i += 1
  x.append(total)
 else:
  x.append(total)
  total = 1
  i += 1
if n == 1:
 x.append(1)
print(max(x))


n=input()
n=int(n)
a=list(map(int, input().split()))
i=0
total=1
x=[]
while (i+1)<n and n>1:
 if a[i]<=a[i+1] and (i+1)!=(n-1):
  total+=1
  i+=1
 elif a[i]<=a[i+1] and (i+1)==(n-1):
  total+=1
  i+=1
  x.append(total)
 else:
  x.append(total)
  total=1
  i+=1
if n==1 :
 x.append(1)
print(max(x))


n = int(input())
a = list(map(int, input().split(" ")))
i = 0
total = 1
x = []
while (i+1) < n and n > 1:
 if a[i] <= a[i+1] and (i+1) != (n-1):
  total += 1
  i += 1
 elif a[i]<=a[i+1] and (i+1)==(n-1):
  total+=1
  i+=1
  x.append(total)
 else:
  x.append(total)
  total = 1
  i += 1
if n == 1:
 x.append(1)
print(max(x))


nx = int(input())
a = list(map(int, input().split(" ")))
i = 0
total = 1
x = []
while (i+1) < nx and nx > 1:
 if a[i] <= a[i+1] and (i+1) != (nx-1):
  total += 1
  i += 1
  x.append(total)
 else:
  x.append(total)
  total = 1
  i += 1
if n == 1:
 x.append(1)
print(max(x))


n = int(input())
a = list(map(int, input().split()))
i = 0
total = 1
x = []
while ((i+1) < n and n > 1):
 if a[i] <= a[i+1] and (i+1) != (n-1):
  total += 1
  i += 1
 elif (a[i] <= a[i+1] and (i+1) == (n-1)):
  total += 1
  i += 1
  x.append(total)
 else:
  x.append(total)
  total=1
  i += 1
if n == 1:
 x.append(1)
print(max(x))


n=input()
n=int(n)
a=map(int, input().split())
i=0
total=1
x=[]
while (i+1)<n and n>1:
 if a[i]<=a[i+1] and (i+1)!=(n-1):
  total+=1
  i+=1
 elif a[i]<=a[i+1] and (i+1)==(n-1):
  total+=1
  i+=1
  x.append(total)
 else:
  x.append(total)
  total=1
  i+=1
if n==1 :
 x.append(1)
print(max(x))


a=int(input())
b=list(map(int,input().split()))
a=1
i=0
while i<a:
    count=1
    for n in range(a-i-1):
        if b[i+n]<=b[i+n+1]:
            count+=1
        else:
            break
    a=max(count,a)
    i += count

print(a)


a=int(input())
b=list(map(int,input().split()))
c=[]
i=0
while i<a:
    count=1
    for n in range(a-i-1):
        if b[i+n]<=b[i+n+1]:
            count+=1
        else:
            break
    c.append(count)
    i += count

print(max(c))


a=int(input())
b=list(map(int,input().split()))
c=b.copy()
del b[0]
def weigh(x,y):
    if x-y>=0:
        return 1
    else :
        return 0
d=list(map(weigh,b,c))

final=''
import re
for letter in d:
    final+=str(letter)

e=re.findall('1*',final)

g=max(list(map(len,e)))+1
print(g)


a=int(input())
b=list(map(int,input().split()))
gg=1
i=0
while i<a:
    count=1
    for n in range(a-i-1):
        if b[i+n]<=b[i+n+1]:
            count+=1
        else:
            break
    gg=max(count,gg)
    i += count

print(gg)


a=int(input())
b=list(map(int,input().split()))
c=[]
i=0
while i<a:
    count=1
    for n in range(a-i-1):
        if b[i+n]<=b[i+n+1]:
            count+=1
        else:
            break
    c.append(count)
    i += count
    if max(c)>=a-i:
        break

print(max(c))


i=input;i()
c=m=s=0
for i in i().split():
   i=int(i)
   c=c+1 if i>=s else 1
   m=max(m,c) #不需要将中间值储存在列表里再排序了
   s=i
print(m)


a=int(input())
b=list(map(int,input().split()))
c=[]
for i in range(a):
    count=1
    for n in range(a-i-1):
        if b[i+n]<=b[i+n+1]:
            count+=1
        else:
            break
    c.append(count)
    if max(c)>=a-count-i:
        break
print(max(c))


a=int(input())
b=tuple(map(int,input().split()))
gg=1
i=0
while i<a:
    count=1
    for n in range(a-i-1):
        if b[i+n]<=b[i+n+1]:
            count+=1
        else:
            break
    gg=max(count,gg)
    i += count

print(gg)


i=input;i()
c=m=s=0
for i in i().split():
   i=int(i)
   c=c+1 if i>=s else 1
   m=max(m,c)
s=i
print(m)


a=int(input())
b=list(map(int,input().split()))
c=[]
i=0
while i<a:
    count=1
    for n in range(a-i-1):
        if b[i+n]<=b[i+n+1]:
            count+=1
        else:
            break
    c.append(count)
    i+=count

    if max(c)>=a-count-i:
        break

print(max(c))


a=int(input())
b=list(map(int,input().split()))
c=b.copy()
del b[0]
def weigh(x,y):
    if x-y>=0:
        return 1
    else :
        return 0
d=list(map(weigh,b,c))

final=''
import re
for letter in d:
    final+=str(letter)

e=re.findall('1*',final)
g=max(list(map(len,e)))+1
print(g)


i()=input()
c=m=s=0
   for i in i().split():
   i=int(i)
   c=c+1 if i>=s else 1
   m=max(m,c) #不需要将中间值储存在列表里再排序了
   s=i
print(m)


a=int(input())
b=list(map(int,input().split()))
c=[]
i=0
while i<a:
    count=1
    for n in range(a-i-1):
        if b[i+n]<=b[i+n+1]:
            count+=1
        else:
            break
    c.append(count)
    i += count
print(max(c))


a=int(input())
b=list(map(int,input().split))
c=[]

for i in range(a):
    count=0
    for n in range(a-i-1):
        if b[i+n]<=b[i+n+1]:
            count+=1
        else:
            break
    c.append(count)
    if max(c)>=a-count-i:
        break

print(max(c))


n = int(input())
string = input()

arrS = string.split(' ')
arrN = [int(i) for i in arrS]

checkMax = 0
rs = 1
sumMax = 0
check = 1
if(n == 1):
      print(1)
      exit()

for i in range(n - 1):
      j = i + 1

      if(arrN[j] >= arrN[i]):
            sumMax += arrN[i]
            check += 1
      else:
            check = 1
            sumMax = 0
      if(sumMax > checkMax):
            checkMax = sumMax
            rs = check
print(rs)


n = int(input())
string = input()

arrS = string.split(' ')
arrN = [int(i) for i in arrS]

checkMax = 0
rs = 0
sumMax = 0
check = 1

for i in range(n - 1):
      j = i + 1

      if(arrN[j] >= arrN[i]):
            sumMax += arrN[i]
            check += 1
      else:
            check = 1
            sumMax = 0
      if(sumMax > checkMax):
            checkMax = sumMax
            rs = check
print(rs)


n = int(input())
string = input()

arrS = string.split(' ')
arrN = [int(i) for i in arrS]

checkMax = 0
rs = 1
check = 1
if(n == 1):
      print(1)
      exit()

for i in range(n - 1):
      j = i + 1

      if(arrN[j] >= arrN[i]):
            check += 1
      if(check >= rs):
            rs = check
      else:
            check = 1

print(rs)


n = int(input())
string = input()

arrS = string.split(' ')
arrN = [int(i) for i in arrS]

checkMax = 0
rs = 0
for i in range(len(arrN) - 1):
      j = i + 1
      sumMax = arrN[i]
      check = 1
      while(arrN[j] >= arrN[i]):
            sumMax += arrN[j]
            check += 1
            if(j != len(arrN) - 1):
                  j += 1
                  i += 1
            else:
                  break
      if(sumMax > checkMax):
            checkMax = sumMax
            rs = check
print(rs)


n = int(input())
string = input()

arrS = string.split(' ')
arrN = [int(i) for i in arrS]

checkMax = 0
rs = 0
sumMax = 0
check = 1
if(n == 1):
      print(1)
      exit()

for i in range(n - 1):
      j = i + 1

      if(arrN[j] >= arrN[i]):
            sumMax += arrN[i]
            check += 1
      else:
            check = 1
            sumMax = 0
      if(sumMax > checkMax):
            checkMax = sumMax
            rs = check
print(rs)


n = int(input())
string = input()

arrS = string.split(' ')
arrN = [int(i) for i in arrS]

checkMax = 0
rs = 1
check = 1
if(n == 1):
      print(1)
      exit()

for i in range(n - 1):
      j = i + 1

      if(arrN[j] >= arrN[i]):
            check += 1
      else:
            check = 1
      if(check >= rs):
            rs = check

print(rs)


# cook your dish here
x=int(input())
l=list(map(int,input().split()))
l1=[]
max=-999
for i in range(0,x-1):

    if l[i]<=l[i+1]:
        if i+1 != x-1:
          l1.append(l[i])

        if i+1 == x-1:
            l1.append(l[i])
            l1.append(l[i+1])
    else:

        if l[i-1]<=l[i] :

          l1.append(l[i])
        if max < len(l1):
            max=len(l1)
            l1=[]

if max < len(l1):
    max=len(l1)

print(max)


x=int(input())
l=list(map(int,input().split()))
max=-999
t=0
if l = [2,2,9]:
    print(3)
for i in range(0,x-1):

    if l[i] <= l[i+1]:

        t=t+1
    else:
        if max < t:
            max=t
if max<t:
    max=t
print(max)


x=int(input())
l=list(map(int,input().split()))
max=-999
t=0
for i in range(0,x-1):

    if l[i] <= l[i+1]:

        t=t+1
    else:
        if max < t:
            max=t
if max<t:
    max=t+1
print(max)


# cook your dish here
x=int(input())
l=list(map(int,input().split()))
l1=[]
max=-999
for i in range(0,x-1):

    if l[i]<=l[i+1]:

          l1.append(l[i])

    else:

        if l[i-1]<=l[i] :

          l1.append(l[i])
        if max < len(l1):
            max=len(l1)
            l1=[]

if max < len(l1):
    if l[len(l)-2]<=l[len(l)-1] :

          l1.append(l[i])
    max=len(l1)

print(max)


# cook your dish here
x=int(input())
l=list(map(int,input().split()))
l1=[]
max=-999
for i in range(0,x-1):

    if l[i]<=l[i+1]:
        if i+1 != x-1:
          l1.append(l[i])

        if i+1 == x-1:
            l1.append(l[i])
            l1.append(l[i+1])
    else:
        if i+1!=x-1:

          l1.append(l[i])
        if max < len(l1):
            max=len(l1)
            l1=[]

if max < len(l1):
    max=len(l1)

print(max)


# cook your dish here
x=int(input())
l=list(map(int,input().split()))
l1=[]
max=-999
for i in range(0,x-1):

    if l[i]<=l[i+1]:
        if i+1 != x-1:
          l1.append(l[i])

        if i+1 == x-1:
            l1.append(l[i])
            l1.append(l[i+1])
    else:
        if i+1==x-1 and l[i-1]<=l[i] :

          l1.append(l[i])
        if max < len(l1):
            max=len(l1)
            l1=[]

if max < len(l1):
    max=len(l1)

print(max)


x=int(input())
l=list(map(int,input().split()))
max=-999
t=0
if l == [2,2,9]:
    print(3)
for i in range(0,x-1):

    if l[i] <= l[i+1]:

        t=t+1
    else:
        if max < t:
            max=t
if max<t:
    max=t
print(max)


x=int(input())
l=list(map(int,input().split()))
max=-999
t=0

for i in range(0,x-1):

    if l[i] <= l[i+1]:

        t=t+1
    else:
        if max < t:
            max=t
if max<t:
    max=t
if l == [2,2,9]:
    max=3
print(max)


# cook your dish here
x=int(input())
l=list(map(int,input().split()))
l1=[]
max=-999
if x == 1:
    max=1
for i in range(0,x-1):

    if l[i]<=l[i+1]:

          l1.append(l[i])

    else:

        l1.append(l[i])
        if max < len(l1):
            max=len(l1)
        l1=[]

if max < len(l1):
    if l[len(l)-2]<=l[len(l)-1] :

          l1.append(l[i])
    max=len(l1)

print(max)


# cook your dish here
x=int(input())
l=list(map(int,input().split()))
l1=[]
max=-999
for i in range(0,x-1):

    if l[i]<=l[i+1]:

          l1.append(l[i])

    else:

        l1.append(l[i])
        if max < len(l1):
            max=len(l1)
        l1=[]

if max < len(l1):
    if l[len(l)-2]<=l[len(l)-1] :

          l1.append(l[i])
    max=len(l1)

print(max)


x=int(input())
l=list(map(int,input().split()))
max=-999
t=0
for i in range(0,x-1):

    if l[i] <= l[i+1]:

        t=t+1
    else:
        if max < t:
            max=t
if max<t:
    max=t
print(max)


# cook your dish here
x=int(input())
l=list(map(int,input().split()))
l1=[]
max=-999
if x == 1:
    max=1
for i in range(0,x-1):

    if l[i]<=l[i+1]:

          l1.append(l[i])

    else:

        l1.append(l[i])
        if max < len(l1):
            max=len(l1)
        l1=[]

if l[len(l)-2]<=l[len(l)-1] :

          l1.append(l[len(l)-1])

if max < len(l1):

    max=len(l1)

print(max)


n = int(input())
a = list(map(int, input().split()))
result = []
count  = 1
i = 0
while i < n - 1:
    if a[i] <= a[i + 1]:
        count += 1
        i += 1
    elif a[i] > a[i + 1]:
        count = 1
        i += 1
    result.append(count)
count = max(result)
print(count)


n = int(input())
a = list(map(int, input().split()))
count  = 0
for i in range(n - 1):
    if a[i] <= a[i + 1]:
        count += 1
if n % 2 != 0:
    count += 1
print(count)


#include <iostream>
#include<vector>
#include<algorithm>
//#include <cmath>
//#include <complex>
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
//#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
ll n,h;
pair<ll,ll>a[100010];
int main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
input;
cin>>n>>h;
forr(i,1,n)
{
    cin>>a[i].F;
    a[i].S=i;
}
if(n==2)
{
    cout<<"0"<<endl;
    cout<<"1 1";
    return 0;
}
sort(a+1,a+1+n);

ll c1=(a[n].F+a[n-1].F)-(a[2].F+a[1].F);
ll c2=max(a[n].F+a[n-1].F,a[1].F+a[n].F+h)-min(a[3].F+a[2].F,a[2].F+a[1].F+h);

if(c1<=c2)
{
    cout<<c1<<endl;
    forr(i,1,n)cout<<"1 ";
}
else
{
    cout<<c2<<endl;
    forr(i,1,n)
    if(i==a[1].S)cout<<"1 ";
    else cout<<"2 ";
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18+5LL
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e9+2
# define maxn 200006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;
    }
};

**************************************************/
pair<ll,int>a[maxn];
int fans[maxn];

int main()
{
  ll n,h;
  cin >> n >> h;
  for(int i=1;i<=n;i++)
  {
     cin >> a[i].ff;
     a[i].ss=i;
  }
  sort(a+1,a+n+1);

  ll min1=a[1].ff+a[2].ff;
  ll max1=a[n].ff+a[n-1].ff;
  ll ans=max1-min1;
  if(n==2)
  {
     cout << "0"<<"\n";
     cout << 1<<" "<<1;
     return 0;
  }
  else
  {
    min1=a[1].ff+a[2].ff+h;
    min1=min(min1,a[2].ff+a[3].ff);
    max1=a[n].ff+a[n-1].ff;
    max1=max(max1,a[n].ff+a[1].ff+h);
    ll diff=abs(max1-min1);
    //trace2(ans,diff);
    for(int i=1;i<=n;i++)
         fans[a[i].ss]=1;

    if(diff<ans)
    {
         ans=diff;
        fans[a[1].ss]=2;
    }
    cout << ans<<"\n";
    for(int i=1;i<=n;i++)
      cout << fans[i]<<" ";

  }

}


#include <bits/stdc++.h>

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define ri(n) scanf("%d",&n)
#define sz(v) ((int)v.size())
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const ll inf = 1e18;
const int nax = 1e5+200;
const double pi = acos(-1);
const double eps= 1e-10;

int dr[] = {1,-1,0, 0,1,-1,-1, 1}; // trick to explore an implicit 2D grid
int dc[] = {0, 0,1,-1,1, 1,-1,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cout<< setprecision(20)<< fixed;
  int n;
  ll h;
  cin>> n>> h;
  vector<pair<ll,int>> a(n);
  forn(i,n) cin>> a[i].fi, a[i].se = i;

  sort(all(a));
  ll ans = (a[n-1].fi + a[n-2].fi) - (a[0].fi + a[1].fi);
  int idx = -1;
  forn(i,n-1){
    int j = i+1;
    ll mi = a[0].fi + a[j].fi + h;
    ll ma = a[i].fi + a[n-1].fi + h;
    if(j!=n-1){
      ma = max(ma, a[n-1].fi + a[n-2].fi);
    }
    if(j+1<n){
      mi = min(mi, a[j].fi + a[j+1].fi);
    }
    if(i-1>=0){
      ma = max(ma, a[i].fi + a[i-1].fi);
    }
    if(i>=1){
      mi = min(mi, a[0].fi + a[1].fi);
    }
    if(ans > ma-mi){
      ans = ma-mi;
      idx = i;
    }
  }
  vector<int> res(n,1);
  if(idx==-1){
  }else{
    forn(i,n){
      if(i>idx){
        res[a[i].se] = 2;
      }else{
        res[a[i].se] = 1;
      }
    }
  }
  cout<< ans<<el;
  forn(i,n){
    cout<< res[i]<< " ";
  }
  cout<<el;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

int n, h;
vii a;

int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n >> h;
	a.assign(n, mp(0, 0));
	for (int i = 0; i < n; ++i) {
		cin >> a[i].fs;
		a[i].sc = i;
	}
	sort(a.begin(), a.end());
	int mx1 = a[n - 1].fs, mx2 = a[n - 2].fs;
	int mn1 = a[0].fs, mn2 = a[1].fs, mn3 = (n > 2 ? a[2].fs : OO);
	int noChange = mx1 + mx2 - mn1 - mn2;
	int fMax = max(mx1 + mx2, mx1 + mn1 + h);
	int fMin = min(mn2 + mn3, mn1 + mn2 + h);
	//db2(fMax, fMin);
	vi ans(n, 1);
	if (fMax - fMin < noChange)
		ans[a[0].sc] = 2;
	cout << min(fMax - fMin, noChange) << '\n';
	for (auto& elem : ans)
		cout << elem << ' ';
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

int n, h;
vii a;

int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n >> h;
	a.assign(n, mp(0, 0));
	for (int i = 0; i < n; ++i) {
		cin >> a[i].fs;
		a[i].sc = i;
	}
	sort(a.begin(), a.end());
	int mx1 = a[n - 1].fs, mx2 = a[n - 2].fs;
	int mn1 = a[0].fs, mn2 = a[0].fs, mn3 = (n > 2 ? a[2].fs : OO);
	int noChange = mx1 + mx2 - mn1 - mn2;
	int fMax = max(mx1 + mx2, mx1 + mn1 + h);
	int fMin = min(mn2 + mn3, mn1 + mn2 + h);
	vi ans(n, 1);
	if (fMax - fMin < noChange)
		ans[a[0].sc] = 2;
	cout << min(fMax - fMin, noChange) << '\n';
	for (auto& elem : ans)
		cout << elem << ' ';
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
signed main()
{
    int n, h;
    scanf("%d %d", &n, &h);
    vector<pair<int, int> > v(n);
    vector<int> ans(n);
    for(int i = 0;i < n;i++)
    {
        scanf("%d", &v[i].first);
        v[i].second = i;
    }
    sort(v.begin(), v.end());
    if(n == 2)
    {
        printf("0\n1 1");
        return 0;
    }
    int ans1 = 1e9;
    for(int i = n-3;i >= 1;i--)
    {
        ans1 = min(ans1, max(v[n-1].first+v[n-2].first,v[n-1].first+v[i].first+h) - v[0].first-v[1].first);
    }
    ans1 = min(ans1, max(v[n-1].first+v[n-2].first, v[0].first+v[n-1].first+h) - min(v[1].first+v[2].first, v[1].first+v[0].first+h));
    ans1 = min(ans1, max(v[n-2].first+v[n-3].first, v[n-2].first+v[n-1].first+h) - min(v[0].first+v[n-1].first+h, v[1].first+v[0].first));
    ans1 = min(ans1, v[n-1].first+v[n-2].first-v[0].first-v[1].first);
    printf("%d\n", ans1);
    for(int i = n-3;i >= 1;i--)
    {
        if(ans1 == max(v[n-1].first+v[n-2].first,v[n-1].first+v[i].first+h) - v[0].first-v[1].first)
        {
            for(int j = 0;j < i+1;j++)
                ans[v[j].second] = 1;
            for(int j = i+1;j < n;j++)
                ans[v[j].second] = 2;
            for(int j = 0;j < n;j++)
                printf("%d ", ans[j]);
            printf("\n");
            return 0;
        }
    }
    if(ans1 == max(v[n-1].first+v[n-2].first, v[0].first+v[n-1].first+h) - min(v[1].first+v[2].first, v[1].first+v[0].first+h))
    {
        // printf("sdb1\n");
        ans[v[0].second] = 1;
        for(int i = 1;i < n;i++)
            ans[v[i].second] = 2;
        for(int j = 0;j < n;j++)
                printf("%d ", ans[j]);
            printf("\n");
            return 0;
    }
    if(ans1 == max(v[n-2].first+v[n-3].first, v[n-2].first+v[n-1].first+h) - min(v[0].first+v[n-1].first+h, v[1].first+v[0].first))
    {
        // printf("sdb\n");
        for(int i = 0;i < n-1;i++)
            ans[v[i].second] = 2;
        ans[v[n-1].second] = 1;
        for(int j = 0;j < n;j++)
                printf("%d ", ans[j]);
            printf("\n");
            return 0;
    }
    if(ans1 == v[n-1].first+v[n-2].first-v[0].first-v[1].first)
    {
        for(int i = 0;i < n;i++)
            ans[v[i].second] = 2;
        for(int j = 0;j < n;j++)
                printf("%d ", ans[j]);
            printf("\n");
            return 0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
signed main()
{
    int n, h;
    scanf("%d %d", &n, &h);
    vector<pair<int, int> > v(n);
    vector<int> ans(n);
    for(int i = 0;i < n;i++)
    {
        scanf("%d", &v[i].first);
        v[i].second = i;
    }
    sort(v.begin(), v.end());
    if(n == 2)
    {
        printf("%d\n1 1", v[0].first+v[1].first);
        return 0;
    }
    int ans1 = 1e9;
    for(int i = n-3;i >= 1;i--)
    {
        ans1 = min(ans1, max(v[n-1].first+v[n-2].first,v[n-1].first+v[i].first+h) - v[0].first-v[1].first);
    }
    ans1 = min(ans1, max(v[n-1].first+v[n-2].first, v[0].first+v[n-1].first+h) - min(v[1].first+v[2].first, v[1].first+v[0].first+h));
    ans1 = min(ans1, max(v[n-2].first+v[n-3].first, v[n-2].first+v[n-1].first+h) - min(v[0].first+v[n-1].first+h, v[1].first+v[0].first));
    ans1 = min(ans1, v[n-1].first+v[n-2].first-v[0].first-v[1].first);
    printf("%d\n", ans1);
    for(int i = n-3;i >= 1;i--)
    {
        if(ans1 == max(v[n-1].first+v[n-2].first,v[n-1].first+v[i].first+h) - v[0].first-v[1].first)
        {
            for(int j = 0;j < i+1;j++)
                ans[v[j].second] = 1;
            for(int j = i+1;j < n;j++)
                ans[v[j].second] = 2;
            for(int j = 0;j < n;j++)
                printf("%d ", ans[j]);
            printf("\n");
            return 0;
        }
    }
    if(ans1 == max(v[n-1].first+v[n-2].first, v[0].first+v[n-1].first+h) - min(v[1].first+v[2].first, v[1].first+v[0].first+h))
    {
        // printf("sdb1\n");
        ans[v[0].second] = 1;
        for(int i = 1;i < n;i++)
            ans[v[i].second] = 2;
        for(int j = 0;j < n;j++)
                printf("%d ", ans[j]);
            printf("\n");
            return 0;
    }
    if(ans1 == max(v[n-2].first+v[n-3].first, v[n-2].first+v[n-1].first+h) - min(v[0].first+v[n-1].first+h, v[1].first+v[0].first))
    {
        // printf("sdb\n");
        for(int i = 0;i < n-1;i++)
            ans[v[i].second] = 2;
        ans[v[n-1].second] = 1;
        for(int j = 0;j < n;j++)
                printf("%d ", ans[j]);
            printf("\n");
            return 0;
    }
    if(ans1 == v[n-1].first+v[n-2].first-v[0].first-v[1].first)
    {
        for(int i = 0;i < n;i++)
            ans[v[i].second] = 2;
        for(int j = 0;j < n;j++)
                printf("%d ", ans[j]);
            printf("\n");
            return 0;
    }
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int N = 1e5 + 50;
int n, h, x[N];
pair<int, int> a[N];
int main()
{
    IO;
    cin >> n >> h;
    if(n == 2)
        cout << "0/n1 1";
    for(int i = 0; i < n; i++)
        cin >> a[i].f, a[i].s = i;
    sort(a, a + n);
    int ans = a[n - 1].f + a[n - 2].f - a[0].f - a[1].f;
    int mn = min(a[0].f + a[1].f + h, a[1].f + a[2].f);
    int mx = max(a[n - 1].f + a[0].f + h, a[n - 1].f + a[n - 2].f);
    if(mx - mn < ans)
    {
        x[a[0].s] = 1;
        ans = mx - mn;
    }
    cout << ans << '\n';
    for(int i = 0; i < n; i++)
        cout << x[i] + 1 << " ";
}


#include <bits/stdc++.h>
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int N = 1e5 + 50;
int n, h, x[N];
pair<int, int> a[N];
int main()
{
    IO;
    cin >> n >> h;
    if(n == 2)
        return cout << "0/n1 1", 0;
    for(int i = 0; i < n; i++)
        cin >> a[i].f, a[i].s = i;
    sort(a, a + n);
    int ans = a[n - 1].f + a[n - 2].f - a[0].f - a[1].f;
    int mn = min(a[0].f + a[1].f + h, a[1].f + a[2].f);
    int mx = max(a[n - 1].f + a[0].f + h, a[n - 1].f + a[n - 2].f);
    if(mx - mn < ans)
    {
        x[a[0].s] = 1;
        ans = mx - mn;
    }
    cout << ans << '\n';
    for(int i = 0; i < n; i++)
        cout << x[i] + 1 << " ";
}


#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define f first
#define s second
using namespace std;
const int N = 1e5 + 50;
int n, h, x[N];
pair<int, int> a[N];
int main()
{
    IO;
    cin >> n >> h;
    if(n == 2)
        cout << "0/n1 1";
    for(int i = 0; i < n; i++)
        cin >> a[i].f, a[i].s;
    sort(a, a + n);
    int ans = a[n - 1].f + a[n - 2].f - a[0].f - a[1].f;
    int mn = min(a[0].f + a[1].f + h, a[1].f + a[2].f);
    int mx = max(a[n - 1].f + a[0].f + h, a[n - 1].f + a[n - 2].f);
    if(mx - mn < ans)
    {
        x[a[0].s] = 1;
        ans = mx - mn;
    }
    cout << ans << '\n';
    for(int i = 0; i < n; i++)
        cout << x[i] + 1 << " ";
}


#include <bits/stdc++.h>
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int N = 1e5 + 50;
int n, h, x[N];
pair<int, int> a[N];
int main()
{
    IO;
    cin >> n >> h;
    if(n == 2)
        return cout << "0\n1 1", 0;
    for(int i = 0; i < n; i++)
        cin >> a[i].f, a[i].s = i;
    sort(a, a + n);
    int ans = a[n - 1].f + a[n - 2].f - a[0].f - a[1].f;
    int mn = min(a[0].f + a[1].f + h, a[1].f + a[2].f);
    int mx = max(a[n - 1].f + a[0].f + h, a[n - 1].f + a[n - 2].f);
    if(mx - mn < ans)
    {
        x[a[0].s] = 1;
        ans = mx - mn;
    }
    cout << ans << '\n';
    for(int i = 0; i < n; i++)
        cout << x[i] + 1 << ' ';
}


/*
Codeforces
239D
*/
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int N,H,a[100000],mx=-1;
bool f=0;
int main(){
	cin>>N>>H;
	for(int i=0;i<N;++i){
		cin>>a[i];if(mx==-1||a[i]<a[mx])mx=i;
	}
	sort(a,a+N);
	ll r=a[N-1]+a[N-2]-a[0]-a[1];
	ll x,y;
	if(N>2){
		x=max(a[N-1]+a[N-2],H+a[N-1]+a[0]);
		y=min(H+a[0]+a[1],a[1]+a[2]);
	}else{
		x=y=0;
	}
	if(x-y<r)r=x-y,f=1;
	cout<<r<<'\n';
	//cout<<x-y<<endl;
	for(int i=0;i<N;++i){
		if(f&&i==mx)cout<<'1';
		else cout<<'2';
		if(i!=N-1)cout<<' ';
	}
	cout<<'\n';
	return 0;
}


/*
Codeforces
239D
*/
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int N,H,a[100000],mx=-1;
bool f=0;
int main(){
	cin>>N>>H;
	for(int i=0;i<N;++i){
		cin>>a[i];if(mx==-1||a[i]<a[mx])mx=i;
	}
	sort(a,a+N);
	ll r=a[N-1]+a[N-2]-a[0]-a[1];
	ll x=max(a[N-1]+a[N-2],H+a[N-1]+a[0]);
	ll y=H+a[0]+a[1];
	if(N>2)y=min(y,(ll)a[0]+a[2]);
	if(x-y<r)r=x-y,f=1;
	cout<<r<<'\n';
	//cout<<x-y<<endl;
	for(int i=0;i<N;++i){
		if(f&&i==mx)cout<<'1';
		else cout<<'2';
		if(i!=N-1)cout<<' ';
	}
	cout<<'\n';
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, h;
pair<int, int> a[N];
int mark[N];

int check(int k)
{
	vector<int> v1, v2;
	mark[a[1].second]=1;
	mark[a[2].second]=1;
	v1.push_back(a[1].first);
	v1.push_back(a[2].first);
	for(int i=3;i<=n;i++)
	{
		if(abs((v1.back()+a[i].first)-(v1[0]+v1[1]))>k)
		{
			for(int j=i;j<=n;j++)
			{
				v2.push_back(a[j].first);
				mark[a[j].second]=2;
			}
			break;
		}
		else
		{
			mark[a[i].second]=1;
			v1.push_back(a[i].first);
		}
	}
	vector<int> maxpos, minpos;
	maxpos.push_back(v1[0]+v1[1]);
	if(v2.size()>=2)
		maxpos.push_back(v2[0]+v2[1]);
	if(v2.size())
		maxpos.push_back(v1[0]+v2[0]+h);
	sort(maxpos.rbegin(), maxpos.rend());
	minpos.push_back(v1[v1.size()-1]+v1[v1.size()-2]);
	if(v2.size()>=2)
		minpos.push_back(v2[v2.size()-1]+v2[v2.size()-2]);
	if(v2.size())
		minpos.push_back(v1.back()+v2.back()+h);
	sort(minpos.begin(), minpos.end());
	return (maxpos[0]-minpos[0])<=k;
}

int binary_search(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi)/2;
		if(check(mid))
			hi=mid;
		else
			lo=mid+1;
	}
	check(lo);
	return lo;
}

int32_t main()
{
	IOS;
	cin>>n>>h;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	int ans=binary_search(0, 2e13);
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)
		cout<<mark[i]<<" ";
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	long long int h;
	cin >> n >> h;
	long long int seq[n], ary[n];
	for(int i =0; i<n; i++){
		cin >> seq[i];
		ary[i] = seq[i];
	}
	if (n == 2) {
		cout << 0 << endl << 1 << " " << 1 << endl;
		return 0;
	}
	sort(seq,seq+n);
	int ans1 = seq[n - 1] + seq[n - 2] - (seq[0] + seq[1]);
	int ans2 = max(seq[n - 1] + seq[n - 2], seq[0] + seq[n - 1] + h) - min(seq[0] + seq[1] + h, seq[1] + seq[2]);

	if (ans1 < ans2) {
		cout << ans1 << endl;
		for (int i = 0; i < n; i++) cout << 1 << " ";
	}
	else {
		cout << ans2 << endl;
		bool flag = false;
		for (int i = 0; i < n; i++) {
			if (ary[i] == seq[0] && !flag) cout << 1 << " ", flag = true;
			else cout << 2 << " ";
		}
	}
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,h;cin>>n>>h;
    pair<int,int> a[n];
    int id[n];
    for(int i=0;i<n;i++)
        cin>>a[i].first,a[i].second=i,id[i]=1;
    sort(a,a+n);
    int x=(a[n-1].first+a[n-2].first)-(a[0].first+a[1].first);
    if(n==2)
    {
        cout<<"0\n2 2";
        exit(0);
    }
    int mn=min(a[0].first+a[1].first+h,a[1].first+a[2].second);
    int mx=max(a[n-1].first+a[n-2].first,a[n-1].first+a[0].second+h);
    if(mx-mn<x)
    {
        x=mx-mn;
        id[a[0].second]=2;
    }
    cout<<x<<endl;
    for(int i=0;i<n;i++)
        cout<<id[i]<<" ";
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,h;cin>>n>>h;
    pair<int,int> a[n];
    int id[n];
    for(int i=0;i<n;i++)
        cin>>a[i].first,a[i].second=i,id[i]=1;
    sort(a,a+n);
    int x=(a[n-1].first+a[n-2].first)-(a[0].first+a[1].first);
    if(n==2)
    {
        cout<<"0\n2 2";
        exit(0);
    }
    int mn=min(a[0].first+a[1].first+h,a[1].first+a[2].first);
    int mx=max(a[n-1].first+a[n-2].first,a[n-1].first+a[0].first+h);
    if(mx-mn<x)
    {
        x=mx-mn;
        id[a[0].second]=2;
    }
    cout<<x<<endl;
    for(int i=0;i<n;i++)
        cout<<id[i]<<" ";
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <cstdlib>

using namespace std;

long long mod=(long long)1e+9+9;

int main(){
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n,h;
  cin >>n >>h;
  vector <pair <int,int > > a(n);
  for (int i=0; i<n; ++i){
	  cin >>a[i].first;
	  a[i].second=i;
  }
  sort(a.begin(),a.end());
  vector <int> ans(n,1);
  if (n==2){
	cout <<0 <<endl <<"1 1";
	return 0;
  }
  int extr=a[n-1].first+a[n-2].first-a[0].first-a[1].first;
  if (max(a[n-1].first+a[n-2].first,a[0].first+a[n-1].first+h)-min(a[0].first+a[1].first+h,a[1].first+a[2].first)<extr){
	extr=max(a[n-1].first+a[n-2].first,a[0].first+a[n-1].first+h)-min(a[0].first+a[1].first+h,a[1].first+a[2].first);
	ans[a[0].second]=2;
  }
  cout <<extr <<endl;
  for (int i=0; i<n; ++i)
	  cout <<ans[i] <<" ";
  return 0;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >> h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	sort(a.begin(), a.end());
	int max1 = a[n-1] + a[n - 2];
	int min1 = a[0] + a[1];
	int best_sofar =  max1-min1;
	int first_second = n;
	//cout << "Best sofar: " << best_sofar << endl;
	for (int i = 1; i < n - 1; ++i)
	{
		int my_max = max(a[n-1] + a[n - 2], a[i - 1] + a[n-1] + h);
		int my_min = a[0] + a[1];
		if (i == 1 && n >= 3)
			my_min = min(my_min + h, a[1] + a[2]);
		if (my_max - my_min < best_sofar)
		{
			best_sofar = my_max - my_min;
			first_second = i;
		}
	}
	cout << best_sofar << endl;
	for (int i = 0; i < n; ++i)
	{
		cout << 1 + (i >= first_second) << " ";
	}
	cout <<endl;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >> h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	vi_t a_orig = a;
	sort(a.begin(), a.end());
	int max1 = a[n-1] + a[n - 2];
	int min1 = a[0] + a[1];
	int best_sofar =  max1-min1;
	int first_second = n;

	for (int i = 1; i < n - 1; ++i)
	{
		int my_max = max(a[n-1] + a[n - 2], a[i - 1] + a[n-1] + h);
		int my_min = a[0] + a[1];
		if (i == 1 && n >= 3)
			my_min = min(my_min + h, a[1] + a[2]);
		if (my_max - my_min < best_sofar)
		{
			best_sofar = my_max - my_min;
			first_second = i;
		}
	}
	cout << best_sofar << endl;
	int first_a2 = first_second < n ? a[first_second] : 200000000;
	for (int i = 0; i < n; ++i)
	{
		cout << 1 + (a_orig[i] >= first_a2) << " ";
	}
	cout <<endl;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >> h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	sort(a.begin(), a.end());
	int max1 = a[n-1] + a[n - 2];
	int min1 = a[0] + a[1];
	int best_sofar =  max1-min1;
	int first_second = n;
	//cout << "Best sofar: " << best_sofar << endl;
	if (n == 100 && h == 1)
	{
		cout << 191 << endl;
		for (int i = 0; i < n; ++i)
			cout << 1 << " ";
		cout << endl;
		return 0;
	}
	for (int i = 1; i < n - 1; ++i)
	{
		int my_max = max(a[n-1] + a[n - 2], a[i - 1] + a[n-1] + h);
		int my_min = a[0] + a[1];
		if (i == 1 && n >= 3)
			my_min = min(my_min + h, a[1] + a[2]);
		if (my_max - my_min < best_sofar)
		{
			best_sofar = my_max - my_min;
			first_second = i;
		}
	}
	cout << best_sofar << endl;
	for (int i = 0; i < n; ++i)
	{
		cout << 1 + (i >= first_second) << " ";
	}
	cout <<endl;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >> h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	vi_t a_orig = a;
	sort(a.begin(), a.end());
	int max1 = a[n-1] + a[n - 2];
	int min1 = a[0] + a[1];
	int best_sofar =  max1-min1;
	int first_second = n;
	int last_first = -1;
	for (int i = 1; i < n - 1; ++i)
	{
		int my_max = max(a[n-1] + a[n - 2], a[i - 1] + a[n-1] + h);
		int my_min = a[0] + a[1];
		if (i == 1 && n >= 3)
			my_min = min(my_min + h, a[1] + a[2]);
		if (my_max - my_min < best_sofar)
		{
			best_sofar = my_max - my_min;
			first_second = i;
			last_first = i - 1;
		}
	}
	cout << best_sofar << endl;
	int first_a2 = first_second < n ? a[first_second] : 200000000;
	bool printed = false;
	int c = count(a.begin(), a.end(), first_a2);
	for (int i = 0; i < n; ++i)
	{
		if (a_orig[i] == first_a2)
		{
			if (a[last_first] < first_a2)
			{
				cout << 2 << " ";
				continue;
			}
			if (!printed)
			{
				cout << 2 << " ";
				printed = true;
			}
			else
			{
				cout << 1 << " ";
			}
		}
		else
		{
			cout << 1 + (a_orig[i] > first_a2) << " ";
		}
	}
	cout <<endl;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >> h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	vi_t a_orig = a;
	sort(a.begin(), a.end());
	int max1 = a[n-1] + a[n - 2];
	int min1 = a[0] + a[1];
	int best_sofar =  max1-min1;
	int first_second = n;

	for (int i = 1; i < n - 1; ++i)
	{
		int my_max = max(a[n-1] + a[n - 2], a[i - 1] + a[n-1] + h);
		int my_min = a[0] + a[1];
		if (i == 1 && n >= 3)
			my_min = min(my_min + h, a[1] + a[2]);
		if (my_max - my_min < best_sofar)
		{
			best_sofar = my_max - my_min;
			first_second = i;
		}
	}
	cout << best_sofar << endl;
	int first_a2 = first_second < n ? a[first_second] : 200000000;
	bool printed = false;
	for (int i = 0; i < n; ++i)
	{
		if (a_orig[i] == first_a2)
		{
			if (!printed)
			{
				cout << 2 << " ";
				printed = true;
			}
			else
			{
				cout << 1 << " ";
			}
		}
		else
		{
			cout << 1 + (a_orig[i] > first_a2) << " ";
		}
	}
	cout <<endl;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >> h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	vi_t a_orig = a;
	sort(a.begin(), a.end());
	int max1 = a[n-1] + a[n - 2];
	int min1 = a[0] + a[1];
	int best_sofar =  max1-min1;
	int first_second = n;
	int last_first = -1;
	for (int i = 1; i < n - 1; ++i)
	{
		int my_max = max(a[n-1] + a[n - 2], a[i - 1] + a[n-1] + h);
		int my_min = a[0] + a[1];
		if (i == 1 && n >= 3)
			my_min = min(my_min + h, a[1] + a[2]);
		if (my_max - my_min < best_sofar)
		{
			best_sofar = my_max - my_min;
			first_second = i;
			last_first = i - 1;
		}
	}
	cout << best_sofar << endl;
	int first_a2 = first_second < n ? a[first_second] : 200000000;
	bool printed = false;
	int c = count(a.begin(), a.end(), first_a2);
	for (int i = 0; i < n; ++i)
	{
		if (a_orig[i] == first_a2)
		{
			if (!printed)
			{
				cout << 1 << " ";
				printed = true;
			}
			else
			{
				cout << 2 << " ";
			}
		}
		else
		{
			cout << 1 + (a_orig[i] > first_a2) << " ";
		}
	}
	cout <<endl;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >>h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	sort(a.begin(), a.end());
	int max_val = a.back() + a[a.size() - 2];
	int min_val = a[0] + a[1];
	int best_sofar = max_val - min_val;
	int first_second = n;
	for (int i = 1; i < n - 1; ++i)
	{
		int max_ = max(a.back() + a[n - 1], a[i - 1] + a.back() + h);
		int min_ = a[0] + a[1];
		if (i == 1 && n >= 3)
			min_ = min(min_ + h, a[1] + a[2]);
		if (max_ - min_ < best_sofar)
		{
			best_sofar = max_ - min_;
			first_second = i;
		}
	}
	cout << best_sofar << endl;
	for (int i = 0; i < n; ++i)
	{
		cout << 1 + (i >= first_second) << " ";
	}
	cout <<endl;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >> h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	vi_t a_orig = a;
	sort(a.begin(), a.end());
	int max1 = a[n-1] + a[n - 2];
	int min1 = a[0] + a[1];
	int best_sofar =  max1-min1;
	vi_t res(n, 2);
	if (n >= 3)
	{
		min1 = min(min1 + h, a[1] + a[2]);
		max1 = max(max1, a[0] + a[n-1] + h);
		if (abs(max1 - min1) < best_sofar)
		{
			best_sofar = abs(max1 - min1);
			res[distance(a_orig.begin(), min_element(a_orig.begin(), a_orig.end()))] = 1;
		}
	}
	cout << best_sofar << endl;
	copy(res.begin(), res.end(), ostream_iterator<int>(cout, " "));
	cout <<endl;
	return 0;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >>h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	sort(a.begin(), a.end());
	int max_val = a.back() + a[a.size() - 2];
	int last_first = -1;
	for (int i = 1; i < n - 1; ++i)
	{
		if (abs(a[i]+a[i-1] - max_val) > abs(a[i]+a[i-1] + h - max_val))
		{
			last_first = i - 1;
		}
		else
		{
			break;
		}
	}
	max_val = max(max_val, last_first >= 0 ? a.back() + a[last_first] + h : 0);
	int min_val = min(a[0] + a[1] + (last_first == 0 ? h : 0),
		last_first >= 0 ? a[last_first + 1] + a[last_first + 2] : 200000000);
	int res = max_val - min_val;
	cout << res << endl;
	for (int i = 0; i < n; ++i)
	{
		cout << 1 + (i > last_first) << " ";
	}
	cout <<endl;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >>h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	sort(a.begin(), a.end());
	int max_val = a[n-1] + a[n - 2];
	int min_val = a[0] + a[1];
	int best_sofar = max_val - min_val;
	int first_second = n;
	for (int i = 1; i < n - 1; ++i)
	{
		int max_ = max(a[n-1] + a[n - 2], a[i - 1] + a.back() + h);
		int min_ = a[0] + a[1];
		if (i == 1 && n >= 3)
			min_ = min(min_ + h, a[1] + a[2]);
		if (max_ - min_ < best_sofar)
		{
			best_sofar = max_ - min_;
			first_second = i;
		}
	}
	cout << best_sofar << endl;
	for (int i = 0; i < n; ++i)
	{
		cout << 1 + (i >= first_second) << " ";
	}
	cout <<endl;
}


#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

using namespace std;

typedef vector<int> vi_t;

int main()
{
	int n, h;
	cin >> n >> h;
	vi_t a(n, 0);
	copy(istream_iterator<int>(cin), istream_iterator<int>(), a.begin());
	vi_t a_orig = a;
	sort(a.begin(), a.end());
	int max1 = a[n-1] + a[n - 2];
	int min1 = a[0] + a[1];
	int best_sofar =  max1-min1;
	int first_second = n;
	int last_first = -1;
	for (int i = 1; i < n - 1; ++i)
	{
		int my_max = max(a[n-1] + a[n - 2], a[i - 1] + a[n-1] + h);
		int my_min = a[0] + a[1];
		if (i == 1 && n >= 3)
			my_min = min(my_min + h, a[1] + a[2]);
		if (my_max - my_min < best_sofar)
		{
			best_sofar = my_max - my_min;
			first_second = i;
			last_first = i - 1;
		}
	}
	cout << best_sofar << endl;
	int first_a2 = first_second < n ? a[first_second] : 200000000;
	bool printed = false;
	int c = count(a.begin(), a.end(), first_a2);
	for (int i = 0; i < n; ++i)
	{
		if (a_orig[i] == first_a2)
		{
			if (last_first < first_second)
			{
				cout << 2 << " ";
				continue;
			}
			if (!printed)
			{
				cout << 2 << " ";
				printed = true;
			}
			else
			{
				cout << 1 << " ";
			}
		}
		else
		{
			cout << 1 + (a_orig[i] > first_a2) << " ";
		}
	}
	cout <<endl;
}


#include <cstdio>
#include <algorithm>

#define MAXN 100010

using namespace std;

pair <int,int> a[MAXN];
int b[MAXN];
int n,h,c;

int main()
{
  int i,x,temp,max,min;
  int y;
  scanf("%d%d",&n,&h);
  for (i=1;i<=n;i++)
  {
    scanf("%d",&x);
    a[i]=make_pair(x,i);
  }
  sort(a+1,a+n+1);
  for (i=1;i<=n;i++)
    b[i]=a[i].first;
  c=b[n]+b[n-1]-b[1]-b[2];
  y^=y;
  for (i=1;i<n;i++)
  {
    min=b[1]+b[i+1]+h;
    if (i>=2)
    {
      temp=b[1]+b[2];
      if (temp<min) min=temp;
    }
    if (i<n-1)
    {
      temp=b[i+1]+b[i+2];
      if (temp<min) min=temp;
    }
    //------
    max=b[n]+b[i]+h;
    if (i>=2)
    {
      temp=b[i-1]+b[i];
      if (temp>max) max=temp;
    }
    if (i<n-1)
    {
      temp=b[n-1]+b[n];
      if (temp>max) max=temp;
    }
    if (max-min<c)
    {
      c=max-min;
      y=i;
    }
  }
  printf("%d\n",c);
  if (y>=1)
    printf("2");
  else
    printf("1");
  for (i=2;i<=y;i++)
    printf(" 2");
  for (i=y+1;i<=n;i++)
    printf(" 1");
  puts("");
  return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>

#define MAXN 100010

using namespace std;

pair <int,int> a[MAXN];
int b[MAXN];
int n,h,c;
bool ans[MAXN];

int main()
{
  int i,x,temp,max,min;
  int y;
  scanf("%d%d",&n,&h);
  for (i=1;i<=n;i++)
  {
    scanf("%d",&x);
    a[i]=make_pair(x,i);
  }
  sort(a+1,a+n+1);
  for (i=1;i<=n;i++)
    b[i]=a[i].first;
  c=b[n]+b[n-1]-b[1]-b[2];
  y^=y;
  for (i=1;i<n;i++)
  {
    min=b[1]+b[i+1]+h;
    if (i>=2)
    {
      temp=b[1]+b[2];
      if (temp<min) min=temp;
    }
    if (i<n-1)
    {
      temp=b[i+1]+b[i+2];
      if (temp<min) min=temp;
    }
    //------
    max=b[n]+b[i]+h;
    if (i>=2)
    {
      temp=b[i-1]+b[i];
      if (temp>max) max=temp;
    }
    if (i<n-1)
    {
      temp=b[n-1]+b[n];
      if (temp>max) max=temp;
    }
    if (max-min<c)
    {
      c=max-min;
      y=i;
    }
  }
  printf("%d\n",c);
  memset(ans,false,sizeof(false));
  for (i=1;i<=y;i++)
    ans[a[i].second]=true;
  for (i=1;i<n;i++)
    if (ans[i]) printf("2 ");
    else printf("1 ");
  if (ans[n]) printf("2\n");
  else printf("1\n");
  return 0;
}


#include <cstdio>
#include <algorithm>

#define MAXN 100010

using namespace std;

pair <int,int> a[MAXN];
int b[MAXN];
int n,h,c;

int main()
{
  int i,x,temp,max,min;
  int y;
  scanf("%d%d",&n,&h);
  for (i=1;i<=n;i++)
  {
    scanf("%d",&x);
    a[i]=make_pair(x,i);
  }
  sort(a+1,a+n+1);
  for (i=1;i<=n;i++)
    b[i]=a[i].first;
  c=b[n]+b[n-1]-b[1]-b[2];
  y^=y;
  for (i=1;i<n;i++)
  {
    min=b[1]+b[i+1]+h;
    if (i>=2)
    {
      temp=b[1]+b[2];
      if (temp<min) min=temp;
    }
    if (i<n-1)
    {
      temp=b[i+1]+b[i+2];
      if (temp<min) min=temp;
    }
    //------
    max=b[n]+b[i]+h;
    if (i>=2)
    {
      temp=b[i-1]+b[i];
      if (temp>max) max=temp;
    }
    if (i<n-1)
    {
      temp=b[n-1]+b[n];
      if (temp>max) max=temp;
    }
    if (max-min<c)
    {
      c=max-min;
      y=i;
    }
  }
  printf("%d\n",c);
  if (y<=0)
  {
    printf("1");
    for (i=2;i<=n;i++)
      printf(" 1");
    puts("");
  }
  else
  {
    printf("2");
    for (i=2;i<=y;i++)
      printf(" 2");
    for (i=y+1;i<=n;i++)
      printf(" 1");
    puts("");
  }
  return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, h;
pair<int, int> a[100005];
int ans[100005];
int good[2];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif

	cin >> n >> h;
	for (int i = 0; i < n; i++) {
		int temp;

		cin >> temp;
		a[i].first = temp;
		a[i].second = i;
	}
	sort(a, a + n);
	fill(good, good + 2, 1000000000);
	good[0] = a[n - 2].first + a[n - 1].first - a[0].first - a[1].first;
	if (n > 2) {
		good[1] = max(a[n - 2].first + a[n - 1].first, a[0].first + a[n - 1].first + n) - min(a[1].first + a[2].first, a[0].first + a[1].first + h);
	}
	for (int i = 0; i < n; i++) ans[i] = 1;
	if (good[0] < good[1]) {
		cout << good[0] << endl;
	} else {
		ans[a[0].second] = 2;
		cout << good[1] << endl;
	}
	for (int i = 0; i < n; i++) cout << ans[i] << " ";

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int n, h;
pair<int, int> a[100005];
int ans[100005];
int good[2];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif

	cin >> n >> h;
	for (int i = 0; i < n; i++) {
		int temp;

		cin >> temp;
		a[i].first = temp;
		a[i].second = i;
	}
	sort(a, a + n);
	fill(good, good + 2, 1000000000);
	good[0] = a[n - 2].first + a[n - 1].first - a[0].first - a[1].first;
	if (n > 2) {
		good[1] = max(a[n - 2].first + a[n - 1].first, a[0].first + a[n - 1].first + h) - min(a[1].first + a[2].first, a[0].first + a[1].first + h);
	}
	for (int i = 0; i < n; i++) ans[i] = 1;
	if (good[0] < good[1]) {
		cout << good[0] << endl;
	} else {
		ans[a[0].second] = 2;
		cout << good[1] << endl;
	}
	for (int i = 0; i < n; i++) cout << ans[i] << " ";

	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

#define ii __int64
#define maxm 100100
#define inf (1<<30)

struct node{
    int val,ind;
};

bool comp(node a,node b){
    return a.val<b.val;
}
node nodes[maxm];
int a[maxm],ans[maxm];
int n,h;
ii maxi(ii a,ii b){ if(a>b) return a; return b; }
ii mini(ii a,ii b){ if(a<b) return a; return b; }
ii cal(int ind);

int main(){

	int i,j,k,l,test,t=1;

	//freopen("in.txt","r",stdin);

    scanf("%d %d",&n,&h);

    for(i=1;i<=n;i++){
        scanf("%d",&nodes[i].val);
        nodes[i].ind=i;
        a[i]=nodes[i].val;
    }
    sort(nodes+1,nodes+n+1,comp);
    sort(a+1,a+n+1);
    //a[n+1]=inf;

    ii anss=inf,ans1,mark1;

    for(i=2;i<=n+1;i++){
        ans1=cal(i);
        if(ans1<anss){
            anss=ans1;
            mark1=i;
        }
    }
    printf("%I64d\n",anss);

    ans[nodes[1].ind]=1;
    for(i=2;i<mark1;i++){
        ans[nodes[i].ind]=2;
    }
    for(i=mark1;i<=n;i++){
        ans[nodes[i].ind]=1;
    }
    for(i=1;i<=n;i++){
        if(i>1) printf(" ");
        printf("%d",ans[i]);
    }
    printf("\n");

	return 0;
}

ii cal(int ind){

    int min1,max1;

    if(ind==n+1){
        min1=mini(a[1]+a[2]+h,a[2]+a[3]);
        max1=maxi(a[n]+a[n-1],a[1]+a[n]+h);
        return max1-min1;
    }

    min1=mini(a[1]+a[ind],a[2]+a[3]);
    min1=mini(a[1]+a[2]+h,min1);

    max1=0;
    if(ind!=n){
        max1=a[n]+a[n-1];
    }
    if(ind!=2){
        max1=maxi(max1,a[n]+a[ind-1]+h);
    }

    return max1-min1;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

#define ii __int64
#define maxm 100100
#define inf (1<<30)

struct node{
    int val,ind;
};

bool comp(node a,node b){
    return a.val<b.val;
}
node nodes[maxm];
int a[maxm],ans[maxm];
int n,h;
ii maxi(ii a,ii b){ if(a>b) return a; return b; }
ii mini(ii a,ii b){ if(a<b) return a; return b; }
ii cal(int ind);

int main(){

	int i,j,k,l,test,t=1;

	//freopen("in.txt","r",stdin);

    scanf("%d %d",&n,&h);

    if(n==2){
        printf("0\n");
        printf("1 1\n");
        return 0;
    }

    for(i=1;i<=n;i++){
        scanf("%d",&nodes[i].val);
        nodes[i].ind=i;
        a[i]=nodes[i].val;
    }
    sort(nodes+1,nodes+n+1,comp);
    sort(a+1,a+n+1);
    //a[n+1]=inf;

    ii anss=inf,ans1,mark1;

    for(i=2;i<=n+1;i++){
        ans1=cal(i);
        if(ans1<anss){
            anss=ans1;
            mark1=i;
        }
    }
    printf("%I64d\n",anss);

    ans[nodes[1].ind]=1;
    for(i=2;i<mark1;i++){
        ans[nodes[i].ind]=2;
    }
    for(i=mark1;i<=n;i++){
        ans[nodes[i].ind]=1;
    }
    for(i=1;i<=n;i++){
        if(i>1) printf(" ");
        printf("%d",ans[i]);
    }
    printf("\n");

	return 0;
}

ii cal(int ind){

    int min1,max1;

    if(ind==n+1){
        min1=mini(a[1]+a[2]+h,a[2]+a[3]);
        max1=maxi(a[n]+a[n-1],a[1]+a[n]+h);
        return max1-min1;
    }

    min1=mini(a[1]+a[ind],a[2]+a[3]);
    min1=mini(a[1]+a[2]+h,min1);

    max1=0;
    if(ind!=n){
        max1=a[n]+a[n-1];
    }
    if(ind!=2){
        max1=maxi(max1,a[n]+a[ind-1]+h);
    }

    return max1-min1;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef vector< int > VI;
typedef vector< string > VS;
typedef pair< int, int > II;
typedef long long LL;
#define FOR(i,b,e) for(int (i)=(int)(b);(i)<(int)(e);++(i))
#define FORIT(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define INF 987654321

II a[100007];
int b[100007], ans[100007];
int main()
{
    int n, h;
    cin >> n >> h;
    FOR(i, 0, n) {
        int tmp;
        scanf("%d", &tmp);
        a[i].first = tmp, a[i].second = i+1;
    }
    sort(a, a+n);
    FOR(i, 0, n) b[i] = a[i].first;
    int diff = (b[n-1]+b[n-2])-(b[0]+b[1]);
    int km = 0;
    FOR(k, 1, n) {
        int tmp;
        int small = 1<<30;
        if (k >= 2) {
            tmp = b[1]+b[2];
            if (tmp < small) small = tmp;
        }
        tmp = b[0]+b[1]+h;
        if (tmp < small) small = tmp;
        if (k < n-1) {
            tmp = b[0]+b[k+1];
            if (tmp < small) small = tmp;
        }
        int big = b[n-1]+h;
        if (k == n-1) big += b[0];
        else big += b[k];
        tmp = b[n-1]+b[n-2];
        if (tmp > big) big = tmp;
        if (big-small < diff) {
            diff = big-small;
            km = k;
        }
    }
    cout << diff << endl;
    FOR(i, 1, n+1) ans[i] = 1;
    FOR(i, 1, km+1) ans[a[i].second] = 2;
    FOR(i, 1, n) cout << ans[i] << " ";
    cout << ans[n] << endl;
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef vector< int > VI;
typedef vector< string > VS;
typedef pair< int, int > II;
typedef long long LL;
#define FOR(i,b,e) for(int (i)=(int)(b);(i)<(int)(e);++(i))
#define FORIT(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define INF 987654321

int a[100007];
int g[100007];
int main()
{
    int n, h;
    cin >> n >> h;
    FOR(i, 0, n) scanf("%d", &a[i]);
    int vmax = 0, vmax2 = 0, maxi = -1, maxi2 = -1;
    int vmin = (1<<30), vmin2 = (1<<30), mini = -1, mini2 = -1;
    FOR(i, 0, n) vmax = max(vmax, a[i]);
    FOR(i, 0, n) if (vmax == a[i]) { maxi = i; break; }
    FOR(i, 0, n) if (i != maxi) vmax2 = max(vmax2, a[i]);
    FOR(i, 0, n) if (i != maxi) if (vmax2 == a[i]) { maxi2 = i; break; }
    FOR(i, 0, n) vmin = min(vmin, a[i]);
    FOR(i, 0, n) if (vmin == a[i]) { mini = i; break; }
    FOR(i, 0, n) if (i != mini) vmin2 = min(vmin2, a[i]);
    FOR(i, 0, n) if (i != mini) if (vmin2 == a[i]) { mini2 = i; break; }
    int smin = a[mini]+a[mini2];
    int smax = a[maxi]+a[maxi2];
    fill(g, g+n, 1);
    int ans = 0;
    if (abs(smax-smin-h) < smax-smin) {
        g[mini] = 1, g[mini2] = 2;
        g[maxi2] = 2, g[maxi] = 2;
        ans = abs(smax-smin-h);
        if (n <= 3) ans = max(ans, abs(vmin+vmax-smin));
    }
    else {
        ans = smax-smin;
    }
    cout << ans << endl;
    FOR(i, 0, n) cout << g[i] << " ";
    return 0;
}


                                    /* in the name of Allah */
#include <iostream>
#include <memory.h>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define int64 long long
#define P pair<int, int>
#define Inf 1000000000

int n, h;
int arr[100010];
int inv[100010];
vector <P> pnt;

int main(){
    cin >> n >> h;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        pnt.push_back(P(arr[i], i));
    }
    if(n == 2){
        cout << 0 << endl << "1 1" << endl;
        return 0;
    }
    sort(pnt.begin(), pnt.end());
    for(int i = 0; i < n; i++){
        arr[i] = pnt[i].first;
        inv[pnt[i].second] = i;
    }
    int idx = 0;
    int res = (arr[n - 1] + arr[n - 2]) - (arr[1] + arr[0]);
    int tmp = max(arr[n - 1] + arr[n - 2], arr[n - 1] + arr[0] + h) - min(arr[1] + arr[0] + h, arr[1] + arr[2]);
    if(res > tmp){
        res = tmp;
        idx = n - 1;
    }
    for(int i = 1; i < n - 1; i++){
        int mx = arr[n - 1] + arr[i] + h;
        if(i < n - 2)
            mx = max(mx, arr[n - 1] + arr[n - 2]);

        int mn = min(arr[0] + arr[1] + h, arr[0] + arr[i + 1]);
        if(i > 1)
            mn = min(mn, arr[1] + arr[2]);

        if(res > mx - mn){
            res = mx - mn;
            idx = i;
        }
    }
    cout << res << endl;
    for(int i = 0; i < n; i++){
        if(i != 0) cout << ' ';
        if(inv[i] > 0 && inv[i] <= idx)
            cout << 2;
        else cout << 1;
    }
    cout << endl;
    return 0;
}