import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
static int n;
static int T;
static char[][] grid;
	public static void main(String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		T = Integer.parseInt(st.nextToken());
		grid = new char[n][n];

		if(T==0){
			printS();
			return;
		}
		if(T>n) System.out.println("NO");
		if(T==n){
			printall();
			return;
		}
		if(n%T==0)fill1();
		else fill2();

		if(T==0)print();
		else System.out.println("NO");
	}

	public static void print(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				System.out.print(grid[i][j]);
			}
			System.out.println("");
		}
	}

	public static void printS(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("S");
			System.out.println("");
		}
	}
	public static void printall(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("L");
			System.out.println("");
		}
	}

	public static void fill1(){
		boolean flag = true;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T>0)T--;
			flag = !flag;
			if(T==0) flag = false;
		}
	}

	public static void fill2(){
		boolean flag = false;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T>0)T--;
			flag = !flag;
			if(T==0) flag = false;
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
static int n;
static int T;
static int T1;
static char[][] grid;
	public static void main(String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		T = Integer.parseInt(st.nextToken());
		grid = new char[n][n];
		T1 = T;
		if(T==1&&n==1){
			System.out.println("L");
			return;
		}
		if(T==0){
			printS();
			return;
		}
		if(T>=n) {
			System.out.println("NO");
			return;
		}

		fill1();

		if(T==0){
			System.out.println("YES");
			print();
		}
		else {
			fill2();
			if(T1==0){
				System.out.println("YES");
				print();
			}
			else{
				System.out.println("NO");
			}
		}
	}

	public static void print(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				System.out.print(grid[i][j]);
			}
			if(i!=n-1)System.out.println("");
		}
	}

	public static void printS(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("S");
			if(i!=n-1)System.out.println("");
		}
	}
	public static void printall(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("L");
			if(i!=n-1)System.out.println("");
		}
	}

	public static void fill1(){
		boolean flag = true;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T>0)T--;
			flag = !flag;
			if(T==0) flag = false;
		}
	}

	public static void fill2(){
		boolean flag = false;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T1>0)T1--;
			flag = !flag;
			if(T1==0) flag = false;
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
static int n;
static int T;
static char[][] grid;
	public static void main(String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		T = Integer.parseInt(st.nextToken());
		grid = new char[n][n];

		if(T==0){
			printS();
			return;
		}
		if(T>n) {
			System.out.println("NO");
			return;
		}
		if(T==n){
			printall();
			return;
		}
		if(n%T==0)fill1();
		else fill2();

		if(T==0)print();
		else System.out.println("NO");
	}

	public static void print(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				System.out.print(grid[i][j]);
			}
			if(i!=n-1)System.out.println("");
		}
	}

	public static void printS(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("S");
			if(i!=n-1)System.out.println("");
		}
	}
	public static void printall(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("L");
			if(i!=n-1)System.out.println("");
		}
	}

	public static void fill1(){
		boolean flag = true;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T>0)T--;
			flag = !flag;
			if(T==0) flag = false;
		}
	}

	public static void fill2(){
		boolean flag = false;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T>0)T--;
			flag = !flag;
			if(T==0) flag = false;
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
static int n;
static int T;
static int T1;
static char[][] grid;
	public static void main(String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		T = Integer.parseInt(st.nextToken());
		grid = new char[n][n];
		T1 = T;

		if(T==0){
			printS();
			return;
		}
		if(T>=n) {
			System.out.println("NO");
			return;
		}

		fill1();

		if(T==0){
			System.out.println("YES");
			print();
		}
		else {
			fill2();
			if(T1==0){
				System.out.println("YES");
				print();
			}
			else{
				System.out.println("NO");
			}
		}
	}

	public static void print(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				System.out.print(grid[i][j]);
			}
			if(i!=n-1)System.out.println("");
		}
	}

	public static void printS(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("S");
			if(i!=n-1)System.out.println("");
		}
	}
	public static void printall(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("L");
			if(i!=n-1)System.out.println("");
		}
	}

	public static void fill1(){
		boolean flag = true;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T>0)T--;
			flag = !flag;
			if(T==0) flag = false;
		}
	}

	public static void fill2(){
		boolean flag = false;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T1>0)T1--;
			flag = !flag;
			if(T1==0) flag = false;
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
static int n;
static int T;
static int T1;
static char[][] grid;
	public static void main(String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		T = Integer.parseInt(st.nextToken());
		grid = new char[n][n];
		T1 = T;

		if(T==0){
			printS();
			return;
		}
		if(T>n) {
			System.out.println("NO");
			return;
		}
		if(T==n){
			printall();
			return;
		}
		fill1();

		if(T==0){
			System.out.println("YES");
			print();
		}
		else {
			fill2();
			if(T1==0){
				System.out.println("YES");
				print();
			}
			else{
				System.out.println("NO");
			}
		}
	}

	public static void print(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				System.out.print(grid[i][j]);
			}
			if(i!=n-1)System.out.println("");
		}
	}

	public static void printS(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("S");
			if(i!=n-1)System.out.println("");
		}
	}
	public static void printall(){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)System.out.print("L");
			if(i!=n-1)System.out.println("");
		}
	}

	public static void fill1(){
		boolean flag = true;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T>0)T--;
			flag = !flag;
			if(T==0) flag = false;
		}
	}

	public static void fill2(){
		boolean flag = false;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(flag) grid[i][j] ='L';
				else grid[i][j] = 'S';
			}
			if(flag&&T1>0)T1--;
			flag = !flag;
			if(T1==0) flag = false;
		}
	}
}


import java.util.Scanner;

public class CodeForce_150508_2 {

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		if (n%2 == 0){
			if (k>((n*n)/2)) {
				System.out.println("NO");
				return;
			}
		}
		else {
			if (k>((n*n)/2)+1) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
		int ct = 1;
		while (ct<=n*n){
			if (ct<=(k*2-1) && ct%2==1 ){
				System.out.print("L");
			} else {
				System.out.print("S");
			}
			if (ct%n == 0){
				System.out.println();
			}
			ct++;
		}

		//System.out.println();

	}

}


import java.util.Scanner;

public class CodeForce_150508_2 {

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		if (n%2 == 0){
			if (k>((n*n)/2)) {
				System.out.println("NO");
				return;
			}
		}
		else {
			if (k>((n*n)/2)+1) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
		if (n%2 == 1){
			int ct = 1;
			while (ct<=n*n){
				if (ct<=(k*2-1) && ct%2==1 ){
					System.out.print("L");
				} else {
					System.out.print("S");
				}
				if (ct%n == 0){
					System.out.println();
				}
				ct++;
			}
		} else {
			int ct = 1;
			while (ct<=n*n){
				if (ct<=(k*2) && ct%2==(((ct-1)/n)+1)%2 ){
					System.out.print("L");
				} else {
					System.out.print("S");
				}
				if (ct%n == 0){
					System.out.println();
				}
				ct++;
			}
		}

		//System.out.println();

	}

}


import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Chau Tuan Kiet - ctkiet35@gmail.com
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int count = in.readInt();
        int num = in.readInt();
        int maxi = (count * count + 1) / 2;
        if(num > maxi){
            out.printLine("NO");
            return;
        }
        out.printLine("YES");
        int[][] a = new int[count][count];
        int idx = 0;
        while (num > 0){
            int x = idx / count;
            int y = idx % count;
            if(count % 2 == 0) y += x%2;
            a[x][y] = 1;
            idx += 2;
            --num;
        }
        for(int i = 0; i < count; i++){
            for(int j = 0; j < count; j++){
                if(a[i][j] == 0) out.print('S');
                else out.print('L');
            }
            out.printLine();
        }
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object...objects) {
        print(objects);
        writer.println();
    }

    public void print(char i) {
        writer.print(i);
    }

    public void printLine(char i) {
        writer.println(i);
    }

    public void close() {
        writer.close();
    }

}


import java.util.Scanner;

public class SeaAndIsland {
    public static void main(String asd[])throws Exception
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        if(k>n*(n+1)/2)
            System.out.println("NO");
        else
        {
            char ch[][]=new char[n][n];
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    ch[i][j]='S';
            if(k!=0)
            {
                int m=1;int g=0;
                for(int i=0;g<k&&i<n;i++)
                {
                    if(m==1)
                        for(int j=0;g<k&&j<n;j+=2)
                        {
                            ch[i][j]='L';g++;
                        }
                    else
                        for(int j=1;g<k&&j<n;j+=2)
                        {
                            ch[i][j]='L';g++;
                        }
                    m=m^1;
                }
            }
            System.out.println("YES");
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<n;j++)
                    System.out.print(ch[i][j]);
                System.out.println();
            }
        }
    }
}


import java.util.Scanner;

public class SeaAndIsland {
    public static void main(String asd[])throws Exception
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        if(k>(n*n+1)/2)
            System.out.println("NO");
        else
        {
            char ch[][]=new char[n][n];
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    ch[i][j]='S';
            if(k!=0)
            {
                int m=1;int g=0;
                for(int i=0;g<k&&i<n;i++)
                {
                    if(m==1)
                        for(int j=0;g<k&&j<n;j+=2)
                        {
                            ch[i][j]='L';g++;
                        }
                    else
                        for(int j=1;g<k&&j<n;j+=2)
                        {
                            ch[i][j]='L';g++;
                        }
                    m=m^1;
                }
            }
            System.out.println("YES");
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<n;j++)
                    System.out.print(ch[i][j]);
                System.out.println();
            }
        }
    }
}


import java.util.Scanner;

public class SeaAndIsland {
    public static void main(String asd[])throws Exception
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int mm=n%2==0?n:n+1;
        if(k>n*(mm)/2)
            System.out.println("NO");
        else
        {
            char ch[][]=new char[n][n];
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    ch[i][j]='S';
            if(k!=0)
            {
                int m=1;int g=0;
                for(int i=0;g<k&&i<n;i++)
                {
                    if(m==1)
                        for(int j=0;g<k&&j<n;j+=2)
                        {
                            ch[i][j]='L';g++;
                        }
                    else
                        for(int j=1;g<k&&j<n;j+=2)
                        {
                            ch[i][j]='L';g++;
                        }
                    m=m^1;
                }
            }
            System.out.println("YES");
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<n;j++)
                    System.out.print(ch[i][j]);
                System.out.println();
            }
        }
    }
}


import java.util.Scanner;

public class SeaAndIsland {
    public static void main(String asd[])throws Exception
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        if(k>n*(n+1)/2)
            System.out.println("NO");
        else
        {
            char ch[][]=new char[n][n];
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    ch[i][j]='S';
            if(k!=0)
            {
                int m=1;int g=0;
                for(int i=0;g<k&&i<n;i++)
                {
                    if(m==1)
                        for(int j=0;g<k&&j<n;j+=2)
                        {
                            ch[i][j]='L';g++;
                        }
                    else
                        for(int j=1;g<k&&j<n;j+=2)
                        {
                            ch[i][j]='L';g++;
                        }
                    m=m^1;
                }
            }
            System.out.println("YES");
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<n;j++)
                    System.out.print(ch[i][j]+" ");
                System.out.println();
            }
        }
    }
}


import java.io.*;
import java.util.*;

public class b302
{
	public static void main(String[] args) throws Exception
	{
		InputReader in = new InputReader(System.in);
		OutputWriter out = new OutputWriter(System.out);
		int n=in.readInt();
		int k=in.readInt();
		if(k>Math.ceil(Math.pow(n,2)/2))
			out.printLine("NO");
		else
		{
			int c=0;
			out.printLine("YES");
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<n;j++)
				{

					if(i%2==0&&j%2==0&&c<k)
					{
						out.print('L');
						c+=1;
					}
					else if(i%2!=0&&j%2!=0&&c<k)
					{
						out.print('L');
						c+=1;
					}
					else
					out.print('S');
				}
				out.printLine();
			}
		}
		out.close();
	}

	private static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				} catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (numChars <= 0)
				return -1;
			}
			return buf[curChar++];
		}
		public int readInt()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}

	private static class OutputWriter
	{
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream)
		{
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer)
		{
			this.writer = new PrintWriter(writer);
		}
 		public void print(Object... objects)
		{
			for (int i = 0; i < objects.length; i++)
			{
				if (i != 0)
				writer.print(' ');
				writer.print(objects[i]);
			}
		}

		public void printLine(Object... objects)
		{
			print(objects);
			writer.println();
		}

		public void close()
		{
			writer.close();
		}

		public void flush()
		{
			writer.flush();
		}

	}
}


import java.util.*;
import java.lang.*;

public class sol{

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int max=0;
		if(n==1){
			if(k==1) System.out.print("YES\nL");
			else System.out.print("NO");
			return;
		}
		if(n%2==0) max=(n/2)*n;
		else{
			max=(((n/2)+1)*((n/2)+1))+(((n/2))*((n/2)));
		}
		if(k>max){
			System.out.print("NO");
		}
		else{
			boolean flg = true,done = true;
			int cnt=0;
			System.out.println("YES");
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(cnt==k) {done=!done;cnt++;}
					if(done && flg){
						System.out.print("L");
						flg=!flg;
						cnt++;
					}
					else if(done && !flg){
						System.out.print("S");
						flg=!flg;
						}
					else System.out.print("S");
				}
				System.out.println();
			}

		}
	}
}


import java.util.*;
import java.lang.*;

public class sol{

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int max=0;
		if(n==1){
			if(k==1) System.out.print("YES\nL");
			else System.out.print("NO");
			return;
		}
		if(n%2==0) max=(n/2)*n;
		else{
			max=(((n/2)+1)*((n/2)+1))+(((n/2))*((n/2)));
		}
		System.out.println(max);
		if(k>max){
			System.out.print("NO");
		}
		else{
			boolean flg = true,done = true;
			int cnt=0;
			System.out.println("YES");
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(cnt==k) {done=!done;cnt++;}
					if(done && flg){
						System.out.print("L");
						flg=!flg;
						cnt++;
					}
					else if(done && !flg){
						System.out.print("S");
						flg=!flg;
						}
					else System.out.print("S");
				}
				System.out.println();
			}

		}
	}
}


import java.util.*;
import java.lang.*;

public class sol{

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int max=0;
		if(n==1){
			if(k==1) System.out.print("YES\nL");
			else if(k==0) System.out.print("YES\nS");
			else System.out.print("NO");
			return;
		}
		if(n%2==0) max=(n/2)*n;
		else{
			max=(((n/2)+1)*((n/2)+1))+(((n/2))*((n/2)));
		}
		if(k>max){
			System.out.print("NO");
		}
		else{
			boolean flg = true,done = true;
			int cnt=0;
			System.out.println("YES");
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(cnt==k) {done=!done;cnt++;}
					if(done && flg){
						System.out.print("L");
						flg=!flg;
						cnt++;
					}
					else if(done && !flg){
						System.out.print("S");
						flg=!flg;
						}
					else System.out.print("S");
				}
				System.out.println();
				if(n%2==0)flg=!flg;
			}

		}
	}
}


import java.util.*;
import java.lang.*;

public class sol{

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int max=0;
		if(n==1){
			if(k==1) System.out.print("YES\nL");
			else System.out.print("NO");
			return;
		}
		if(n%2==0) max=(n/2)*n;
		else{
			max=(((n/2)+1)*((n/2)+1))+(((n/2))*((n/2)));
		}
		if(k>max){
			System.out.print("NO");
		}
		else{
			boolean flg = true,done = true;
			int cnt=0;
			System.out.println("YES");
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(cnt==k) {done=!done;cnt++;}
					if(done && flg){
						System.out.print("L");
						flg=!flg;
						cnt++;
					}
					else if(done && !flg){
						System.out.print("S");
						flg=!flg;
						}
					else System.out.print("S");
				}
				System.out.println();
				if(n%2==0)flg=!flg;
			}

		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Islands {

	public static void main(String[] args) {
		double n, numIslands;
		double max;

		String[] splitLine;
		String line;
		BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
		try {
			line = scanner.readLine();
			splitLine = line.split(" ");
			n = Double.parseDouble(splitLine[0]);
			numIslands = Integer.parseInt(splitLine[1]);
			max = Math.pow(Math.ceil(n/2), 2) + Math.pow(Math.floor(n/2), 2);
			if (numIslands > max) {
				System.out.println("NO");
				return;
			}
			System.out.println("YES");
			int islandsCreated = 0;
			for (int i = 0; i < n; i++) {
				int offsetter = 0;
				if (i % 2 == 1)
					offsetter = 1;
				for (int j = 0; j < n; j++) {
					if (j == offsetter && islandsCreated < numIslands) {
						System.out.print("L");
						offsetter += 2;
						islandsCreated++;
					}
					else {
						System.out.print("S");
					}
				}
				System.out.println("");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Islands {

	public static void main(String[] args) {
		double n, numIslands;
		double max;

		String[] splitLine;
		String line;
		BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
		try {
			line = scanner.readLine();
			splitLine = line.split(" ");
			n = Double.parseDouble(splitLine[0]);
			numIslands = Integer.parseInt(splitLine[1]);
			max = Math.pow(Math.ceil(n/2), 2) + Math.pow(Math.floor(n/2), 2);
			if (numIslands > max) {
				System.out.println("NO");
				return;
			}
			int islandsCreated = 0;
			for (int i = 0; i < n; i++) {
				int offsetter = 0;
				if (i % 2 == 1)
					offsetter = 1;
				for (int j = 0; j < n; j++) {
					if (j == offsetter && islandsCreated < numIslands) {
						System.out.print("L");
						offsetter += 2;
						islandsCreated++;
					}
					else {
						System.out.print("S");
					}
				}
				System.out.println("");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;

public class test {

	static int N,K;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		String[] input = br.readLine().split(" ");
		N = Integer.parseInt(input[0]);
		K = Integer.parseInt(input[1]);
		boolean res = false;

		char[][] initMap = new char[N][N];
		for(int i=0; i<N; ++i) {
			for(int j=0; j<N; ++j) {
				initMap[i][j]='S';
			}
		}

		char[][] map = null;
		if( N>=1 && N<=100 && K>=0 && K<=N*N ) {
			for(int i=0; i<N; ++i) {
				map = deepCopy(initMap);

				int j=0;
				for(; j<K; ++j) {
					if(i+(2*j)<N) {
						for(int k=0; k<N; ++k)
							map[i+(2*j)][k] = 'L';
					} else
						break;
				}

				if(j==K) {
					res = true;
					break;
				}
			}

			if(res==false) {
				map = deepCopy(initMap);
				int k=0;
				for(int i=0; i<N; ++i) {
					for( int j=0; j<N; ++j) {
						if( canPlace(map,i,j) == true ) {
							map[i][j] = 'L';
							++k;
						}
						if( k==K )
							break;
					}

					if(k==K)
						break;
				}
				if( k==K)
					res = true;
			}
		}

		if( res==true) {
			bw.write("YES");
			for(int i=0; i<N; ++i) {
				bw.newLine();
				bw.write(map[i]);
			}
		} else {
			bw.write("NO");
		}

		bw.close();
		br.close();
	}

	static char[][] deepCopy(char[][] src) {
		char[][] dst = new char[src.length][];
		for(int i=0; i<src.length; ++i)
			dst[i] = Arrays.copyOf(src[i], src[i].length);
		return dst;
	}

	static boolean canPlace(char[][] map, int col, int row) {
		if( checkUp(map, col, row) && checkDown(map,col,row) &&
				checkLeft(map,col,row) && checkRight(map,col,row) )
			return true;

		return false;
	}

	static boolean checkUp(char[][] map, int col, int row) {
		if( (col-1) >= 0 && map[col-1][row] == 'L')
			return false;

		return true;
	}

	static boolean checkDown(char[][] map, int col, int row) {
		if( (col+1) < N && map[col+1][row] == 'L')
			return false;

		return true;
	}

	static boolean checkLeft(char[][] map, int col, int row) {
		if( (row-1) >= 0 && map[col][row-1] == 'L')
			return false;

		return true;
	}

	static boolean checkRight(char[][] map, int col, int row) {
		if( (row+1) < N && map[col][row+1] == 'L')
			return false;

		return true;
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class test {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		String[] input = br.readLine().split(" ");
		int N = Integer.parseInt(input[0]);
		int K = Integer.parseInt(input[1]);
		boolean res = false;

		String lineS="S";
		String lineL="L";
		for(int i=0; i<N-1; ++i) {
			lineS += "S";
			lineL += "L";
		}

		String[] initMap = new String[N];
		for(int i=0; i<N; ++i) {
			initMap[i] = lineS;
		}

		String[] map = new String[N];
		if( N>=1 && N<=100 && K>=0 && K<=N*N ) {
			for(int i=0; i<N; ++i) {
				map = initMap.clone();

				int j=0;
				for(; j<K; ++j) {
					if(i+(2*j)<N)
						map[i+(2*j)] = lineL;
					else
						break;
				}

				if(j==K) {
					res = true;
					break;
				}
			}
		}

		if( res==true) {
			bw.write("YES");
			for(int i=0; i<N; ++i) {
				bw.newLine();
				bw.write(map[i]);
			}
		} else {
			bw.write("NO");
		}

		bw.close();
		br.close();
	}

}


package island;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class test {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		String[] input = br.readLine().split(" ");
		int N = Integer.parseInt(input[0]);
		int K = Integer.parseInt(input[1]);
		boolean res = false;

		String lineS="S";
		String lineL="L";
		for(int i=0; i<N-1; ++i) {
			lineS += "S";
			lineL += "L";
		}

		String[] initMap = new String[N];
		for(int i=0; i<N; ++i) {
			initMap[i] = lineS;
		}

		String[] map = new String[N];
		if( N>=1 && N<=100 && K>=0 && K<=N*N && K*2 < N) {
			for(int i=0; i<N; ++i) {
				map = initMap.clone();

				int j=0;
				for(; j<K; ++j) {
					if(i+(2*j)<N)
						map[i+(2*j)] = lineL;
					else
						break;
				}

				if(j==K) {
					res = true;
					break;
				}
			}
		}

		if( res==true) {
			bw.write("YES");
			for(int i=0; i<N; ++i) {
				bw.newLine();
				bw.write(map[i]);
			}
		} else {
			bw.write("NO");
		}

		bw.close();
		br.close();
	}

}


#include<bits/stdc++.h>
using namespace std;
#define N 100005
int n,a[N],ans=0;
stack<int > s;
stack<int > s1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		while(!s.empty()&&a[i]>a[s.top()]) s.pop();
		if(!s.empty())
		ans=max(ans,a[s.top()]^a[i]);
		s.push(i);
	}
	for(int i=n;i>=1;i--){
		while(!s.empty()&&a[i]>a[s1.top()]) s.pop();
		if(!s1.empty())
		ans=max(ans,a[s1.top()]^a[i]);
		s1.push(i);
	}
	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,i,j,sum=0,maxx=-1e16,a[100001];
stack <ll> b;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		while(b.size())
		{
			maxx=max(maxx,a[i]^b.top());
			if(b.top()>a[i])
			{
				break;
			}
			b.pop();
		}
		b.push(a[i]);
	}
	cout<<maxx;
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

const int N = 1e5 + 5;

int n,a[N],s[N];

int solve()
{
    int ret = 0 , top = 0;
    for(int i=0;i<n;i++)
    {
        while(top && a[s[top]] < a[i])
            --top;
        if(top)
            ret = max(ret,a[s[top]] ^ a[i]);
        s[++top] = i;
    }
    return ret;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int ans = solve();
    reverse(a,a+n);
    ans = max(ans,solve());
    printf("%d\n",ans);
    return 0;
}


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

const int N = 1e5 + 7;

int arr[N], l[N], r[N];

stack <int> stk;

int32_t main() {
        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n; cin >> n;
        for(int i = 1; i <= n; i++) {
                cin >> arr[i];
        }

        int res = 0;

        for(int i = 1; i <= n; i++) {
                while(!stk.empty() && arr[stk.top()] < arr[i]) {
                        r[stk.top()] = i; stk.pop();
                }
                if(stk.size()) l[i] = stk.top();
                stk.push(i);
        }

        for(int i = 1; i <= n; i++) {
                if(l[i]) res = max(res, arr[i] ^ arr[l[i]]);
                if(r[i]) res = max(res, arr[i] ^ arr[r[i]]);
        }

        cout << res << endl;

}


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

const int N = 1e5 + 7;

int arr[N];

int combine(int i, int j) {
        return arr[i] > arr[j] ? i : j;
}

struct RMQ {
        vector <int> t;
        int n;
        RMQ(int n) : n(n) {
                t.resize(n << 1);
        }
        void build(int a[]) {
                for(int i = 0; i < n; i++) t[n + i] = i;
                for(int i = n - 1; i > 0; --i) t[i] = combine(t[i << 1], t[i << 1 | 1]);
        }

        int query(int l, int r) { int res = l;
                for(l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
                        if(l & 1) res = combine(res, t[l++]);
                        if(r & 1) res = combine(res, t[--r]);
                }
                return res;
        }
};

int dnc(int l, int r, RMQ &SegTree) {
        if(l >= r) return 0;
        int x = SegTree.query(l, r);
        int res = 0;
        if(l < x) res = max(res, arr[x] ^ arr[SegTree.query(l, x - 1)]);
        if(r > x) res = max(res, arr[x] ^ arr[SegTree.query(x + 1, r)]);
        return max(res, max(dnc(l, x - 1, SegTree), dnc(x + 1, r, SegTree)));
}

int main() {
        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n; cin >> n; RMQ SegTree(n + 1);
        for(int i = 1; i <= n; i++) {
                cin >> arr[i];
        }
        SegTree.build(arr);
        cout << dnc(1, n, SegTree) << endl;

}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

#define LOWBIT(x) ((x)&(-x))

#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())

#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

inline int gc(){
    static const int BUF = 1e7;
    static char buf[BUF], *bg = buf + BUF, *ed = bg;

    if(bg == ed) fread(bg = buf, 1, BUF, stdin);
    return *bg++;
}

inline int ri(){
    int x = 0, f = 1, c = gc();
    for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
    for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
    return x*f;
}

typedef long long LL;
typedef unsigned long long uLL;
const int inf = 1e9 + 9;
const LL mod = 1e9 + 7;
const int maxN = 1e5 + 7;

int n;
int s[maxN];
int ans[maxN];

int main(){
    while(cin >> n) {
        // highBit最高二进制差异位，比如{101100, 101101, 101011, 101010}，
        // 那么highBit = 000100，因为4个数有共同的高3位101，到第四位不同
        int max_1 = -1, min_1 = inf, highBit = 0;
        int ans = -1;
        For(i, 1, n) {
            cin >> s[i];
            highBit |= s[i];
            max_1 = max(max_1, s[i]);
            min_1 = min(min_1, s[i]);
        }

        while(highBit & ~LOWBIT(highBit)) highBit &= ~LOWBIT(highBit);

        while(!((max_1 & highBit) ^ (min_1 & highBit))) {
            max_1 &= ~highBit;
            min_1 &= ~highBit;
            highBit >>= 1;
        }

        For(i, 1, n) {
            if(s[i] & highBit) {
                int tmp_max = -1;
                For(j, i + 1, n) {
                    if(s[j] & highBit) {
                        i = j - 1;
                        break;
                    }
                    tmp_max = max(tmp_max, s[j]);
                    ans = max(ans, tmp_max ^ s[i]);
                }
            }
        }
        rFor(i, n, 1) {
            if(s[i] & highBit) {
                int tmp_max = -1;
                rFor(j, i - 1, 1) {
                    if(s[j] & highBit) {
                        i = j + 1;
                        break;
                    }
                    tmp_max = max(tmp_max, s[j]);
                    ans = max(ans, tmp_max ^ s[i]);
                }
            }
        }

        cout << ans <<endl;
    }
    return 0;
}


#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 100010;

int num[N] = {};

int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> num[i];
    stack<int> ans;
    vector<int> ans1;
    for(int i=n-1;i>=0;i--)
    {
        while(!ans.empty() && num[ans.top()] < num[i])
        {
            ans1.push_back(num[ans.top()]|num[i]);
            ans.pop();
        }
        if(!ans.empty())
           ans1.push_back(num[ans.top()]|num[i]);
        ans.push(i);
    }
    sort(ans1.begin(),ans1.end());
    cout << ans1[ans1.size()-1] << endl;
    return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

#define LOWBIT(x) ((x)&(-x))

#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())

#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

inline int gc(){
	static const int BUF = 1e7;
	static char buf[BUF], *bg = buf + BUF, *ed = bg;

	if(bg == ed) fread(bg = buf, 1, BUF, stdin);
	return *bg++;
}

inline int ri(){
	int x = 0, f = 1, c = gc();
	for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
	for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
	return x*f;
}

typedef long long LL;
typedef unsigned long long uLL;
const int inf = 1e9 + 9;
const LL mod = 1e9 + 7;
const int maxN = 1e5 + 7;

int n;
int s[maxN];
int ans[maxN];

int main(){
	while(cin >> n) {
		// highBit最高二进制差异位，比如{101100, 101101, 101011, 101010}，
		// 那么highBit = 000100，因为4个数有共同的高3位101，到第四位不同
		int max_1 = -1, min_1 = inf, highBit = 0;
		int ans = -1;
		For(i, 1, n) {
			cin >> s[i];
			highBit |= s[i];
			max_1 = max(max_1, s[i]);
			min_1 = min(min_1, s[i]);
		}

		while(highBit & ~LOWBIT(highBit)) highBit &= ~LOWBIT(highBit);

		while(!((max_1 & highBit) ^ (min_1 & highBit))) {
			max_1 &= ~highBit;
			min_1 &= ~highBit;
			highBit >>= 1;
		}

		For(i, 1, n) {
			if(s[i] & highBit) {
				int tmp_max = -1;
				For(j, i + 1, n) {
					if(s[j] & highBit) {
						i = j - 1;
						break;
					}
					tmp_max = max(tmp_max, s[j]);
					ans = max(ans, tmp_max ^ s[i]);
				}
			}
		}
		rFor(i, n, 1) {
			if(s[i] & highBit) {
				int tmp_max = -1;
				rFor(j, i - 1, 1) {
					if(s[j] & highBit) {
						i = j + 1;
						break;
					}
					tmp_max = max(tmp_max, s[j]);
					ans = max(ans, tmp_max ^ s[i]);
				}
			}
		}

		cout << ans <<endl;
	}
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int array[10010];
    memset(array,0,sizeof(array));
    for(int i=0;i<n;i++)
        cin >> array[i];
    stack<int> monotonous;
    stack<int> mono1;
    stack<int> ans;
    for(int i=0;i<n;i++)
    {
        while(!monotonous.empty() && array[monotonous.top()] < array[i])
            monotonous.pop();
        if(!monotonous.empty())
        {
            int temp = array[i]^array[monotonous.top()];
            if(ans.empty() || ans.top()<temp)
                ans.push(temp);
        }
        monotonous.push(i);
    }
    for(int i=n-1;i>=0;i--)
    {
        while(!mono1.empty() && array[mono1.top()] < array[i])
            mono1.pop();
        if(!mono1.empty())
        {
            int temp = array[i]^array[mono1.top()];
            if(ans.empty() || ans.top()<temp)
                ans.push(temp);
        }
        mono1.push(i);
    }
    cout << ans.top() << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int array[10010];
    memset(array,0,sizeof(array));
    for(int i=0;i<n;i++)
        cin >> array[i];
    stack<int> monotonous;
    stack<int> ans;
    for(int i=0;i<n;i++)
    {
        while(!monotonous.empty() && array[monotonous.top()] < array[i])
            monotonous.pop();
        if(!monotonous.empty())
        {
            int temp = array[i]^array[monotonous.top()];
            if(ans.empty() || ans.top()<temp)
                ans.push(temp);
        }
        monotonous.push(i);
    }
    while(!monotonous.empty())
        monotonous.pop();
    for(int i=n-1;i>=0;i--)
    {
        while(!monotonous.empty() && array[monotonous.top()] < array[i])
            monotonous.pop();
        if(!monotonous.empty())
        {
            int temp = array[i]^array[monotonous.top()];
            if(ans.empty() || ans.top()<temp)
                ans.push(temp);
        }
        monotonous.push(i);
    }
    cout << ans.top() << endl;
    return 0;
}


ajogj
ajgoja
jvoajflmv
ajovjl;
jpoajdpkda
ahfoja;gkpakgpka;definelavjolj


#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 100010;

int num[N] = {};

int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> num[i];
    stack<int> ans;
    vector<int> ans1;
    for(int i=n-1;i>=0;i--)
    {
        while(!ans.empty() && num[ans.top()] < num[i])
        {
            ans1.push_back(num[ans.top()]^num[i]);
            ans.pop();
        }
        if(!ans.empty())
           ans1.push_back(num[ans.top()]^num[i]);
        ans.push(i);
    }
    sort(ans1.begin(),ans1.end());
    cout << ans1[ans1.size()-1] << endl;
    return 0;
}


//题意：给你一个数字序列，找出该序列的所有子序列中最大值与次大值的异或值的最大值。
//思路：从头到尾，从尾到头各跑一遍单调栈。以当前要进栈的值作为次大值，在之前进栈的值中找一个离当前值最近的最大值，这两个值异或。
//之所以要跑两遍单调栈，是因为如果以当前数作为次大值，那么最大值一定在该数的左侧或者右侧，因为单调栈就是寻找某个数左边和右边比这个数小/大且离这个数最近的数。
//所以从头和从尾各跑一遍，就可以把相对于当前数（次大值）的最大值在左侧和右侧的情况都考虑到。

#include <iostream>
#include <stack>

using namespace std;

const int MaxNum = 100010;
int array[MaxNum];
stack<int> s1;
stack<int> s2;

int main() {
    int ans = 0;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &array[i]);
    }

    for(int i = 0; i < n; i++) {
        while(!s1.empty() && array[i] > s1.top()) {
            s1.pop();
        }
        if(!s1.empty()) {
            ans = max(ans,s1.top()^array[i]);
        }
        s1.push(array[i]);
    }

    for(int i = n - 1; i >= 0; i--) {
        while(!s2.empty() && array[i] > s2.top()) {
            s2.pop();
        }
        if(!s2.empty()) {
            ans = max(ans,s2.top()^array[i]);
        }
        s2.push(array[i]);
    }
    printf("%d",ans);
}


#include <iostream>
#include <stack>

using namespace std;

const int MaxNum = 100010;
int array[MaxNum];
stack<int> s1;
stack<int> s2;

int main() {
    int ans = 0;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &array[i]);
    }

    for(int i = 0; i < n; i++) {
        while(!s1.empty() && array[i] > s1.top()) {
            s1.pop();
        }
        if(!s1.empty()) {
            ans = max(ans,s1.top()^array[i]);
        }
        s1.push(array[i]);
    }

    for(int i = n - 1; i >= 0; i--) {
        while(!s2.empty() && array[i] > s2.top()) {
            s2.pop();
        }
        if(!s2.empty()) {
            ans = max(ans,s2.top()^array[i]);
        }
        s2.push(array[i]);
    }
    printf("%d",ans);
}


#include <bits/stdc++.h>
using namespace std;
int ans = 0, a;
vector<int> st;
int main() {
  cin >> a;
  while (cin >> a) {
    while (st.size() and (ans = max(ans, st.back()^a), st.back() < a)) st.pop_back();
    st.push_back(a);
  }
  cout << ans << '\n';
}


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

class Solution {
  int n, ans = 0;
  vector<int> st;
public:
  void run() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
      int a; cin >> a;
      while (st.size() and st.back() < a)
        ans = max(ans, st.back() xor a), st.pop_back();
      if (st.size()) ans = max(ans, a xor st.back());
      st.push_back(a);
    }
    cout << ans << '\n';
  }
};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  Solution().run();
}


//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

using namespace std;

int const N = 1e5+20;
int n, a[N], st[N], sz, ans;

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i ++) cin >> a[i];
	for (int i = 0; i < n; i ++){
	  	if (sz) ans = max(ans, a[i] ^ a[st[sz-1]]);
		while (sz-1 >= 0 && a[i] > a[st[sz-1]]){
			sz --;
	  		if (sz) ans = max(ans, a[i] ^ a[st[sz-1]]);
		}
		st[sz++] = i;
	}
	cout << ans << '\n';
}


//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

using namespace std;

int const N = 1e5+20;
int n, a[N], st[N], sz, ans;

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i ++) cin >> a[i];
	for (int i = 0; i < n; i ++){
		while (sz-1 >= 0 && a[i] > a[st[sz-1]]){
			ans = max(ans, a[i] ^ a[st[sz-1]]);
			sz --;
		}
		st[sz++] = i;
	}
	sz = 0;
	for (int i = n-1; i >= 0; i--){
		while (sz-1 >= 0 && a[i] > a[st[sz-1]]){
			ans = max(ans, a[i] ^ a[st[sz-1]]);
			sz --;
		}
		st[sz++] = i;
	}
	cout << ans << '\n';
}


#include <bits/stdc++.h>

#define inc(i, a, b) for (int i = a; i <= b; i++)
#define dec(i, a, b) for (int i = a; i >= b; i--)

using namespace std;

typedef long long LL;

const int MAX_N = 1e5 + 5;
const int MAX_M = 2e5 + 5;
const int INF = 0x3f3f3f3f;

int n, s[MAX_N], sp, stk[MAX_N], ans;

void solve() {
	scanf("%d", &n);
	inc(i, 1, n) scanf("%d", s + i);
	inc(i, 1, n) {
		while (sp > 0 && s[stk[sp]] < s[i]) sp--;
		if (sp > 0) ans = max(ans, s[stk[sp]] ^ s[i]);
		stk[++sp] = i;
	}
	inc(i, n, 1) {
		while (sp > 0 && s[stk[sp]] < s[i]) sp--;
		if (sp > 0) ans = max(ans, s[stk[sp]] ^ s[i]);
		stk[++sp] = i;
	}
	printf("%d\n", ans);
}

int main() {
	//ios::sync_with_stdio(false);
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	solve();
	return 0;
}


#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;

int n;
int a[100000+10];
int l[100000+10];
int r[100000+10];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);

	stack<int>s1,s2;

	for(int i=n;i>=1;i--)
	{
		while(!s1.empty()&&a[s1.top()]<a[i]) s1.pop();

		if(s1.empty()) l[i]=n+1;
		else l[i]=s1.top();

		s1.push(i);
	}

	for(int i=1;i<=n;i++)
	{
		while(!s2.empty()&&a[s2.top()]<a[i]) s2.pop();

		if(s2.empty()) r[i]=0;
		else r[i]=s2.top();

		s2.push(i);
	}

	int ans=-1;

	for(int i=1;i<=n;i++)
	{
		if(l[i]!=n+1)
			ans=max(ans,a[i]^a[l[i]]);
		if(r[i]!=0)
			ans=max(ans,a[i]^a[r[i]]);
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<string>
#include<deque>
#include<stack>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define mod 1000000007
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    stack<int> s;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int ans = 0;
    s.push(a[1]);
    for(int i=2; i<=n ;i++)
    {
        while(!s.empty() && a[i]>s.top())
        {
            ans = max(ans,a[i]^s.top());
            s.pop();
        }
        if(!s.empty())
            ans = max(ans,a[i]^s.top());
        s.push(a[i]);
    }
    printf("%d\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <cmath>
#define ll long long
using namespace std;
const int maxn=1e5+19;
int n;
int a[maxn];
int l[maxn];///右边第一个比它大的数的位置
int r[maxn];///左边第一个比它大的数的位置
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	stack<int> s;
	stack<int> s2;
	for(int i=n;i>=1;i--)
	{
		while(s.size()&&a[s.top()]<a[i])
			s.pop();
		if(s.empty())
			l[i]=n+1;
		else
			l[i]=s.top();
		s.push(i);
	}

	for(int i=1;i<=n;i++)
	{
		while(s2.size()&&a[s2.top()]<a[i])
			s2.pop();
		if(s2.empty())
			r[i]=0;
		else
			r[i]=s2.top();
		s2.push(i);
	}
	int maxx=-1;
	for(int i=1;i<=n;i++)
	{
		if(l[i]!=n+1)
			maxx=max(maxx,a[i]^a[l[i]]);
		if(r[i]!=0)
			maxx=max(maxx,a[i]^a[r[i]]);
	}
	cout<<maxx<<endl;
}


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

typedef long long ll;

int main(){

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,mx=0,x;
    cin>>n;
    stack<ll>d;
    for(ll i=0;i<n;i++){
        cin>>x;
        if(d.empty()){
            d.push(x);
        }
        else{
            while(!d.empty() && x>d.top()){
                if((x^d.top())>mx){
                    mx=x^d.top();
                }
                d.pop();
            }
            if(!d.empty() && (x^d.top())>mx){
                mx=x^d.top();
            }
            d.push(x);
        }
    }
    cout<<mx;
}


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

typedef long long ll;

int main(){

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,mx=0,x;
    cin>>n;
    stack<int>d;
    for(int i=0;i<n;i++){
        cin>>x;
        if(d.empty()){
            d.push(x);
        }
        else{
            while(!d.empty() && x>d.top()){
                if((x^d.top())>mx){
                    mx=x^d.top();
                }
                d.pop();
            }
            if((x^d.top())>mx){
                mx=x^d.top();
            }
            d.push(x);
        }
    }
    cout<<mx;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,ans,t,maxn,tal[1010101],zhi[1010101];
int q[1010101<<1];
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
    scanf("%d",&tal[i]);
    while(t>0&&q[t-1]<=tal[i]){ans=max(ans,tal[i]^q[t]);t--;}
    q[++t]=tal[i];
  }printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
int n,m,ans,t,maxn,tal[1010101],zhi[1010101];
int q[1010101<<1];
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
    scanf("%d",&tal[i]);
    while(t>0&&q[t]<=tal[i]){ans=max(ans,tal[i]^q[t]);t--;}
    q[++t]=tal[i];
  }printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,t,maxn,tal[1010101],zhi[1010101];
long long q[1010101<<1];
int main()
{
  scanf("%lld",&n);
  for(int i=1;i<=n;i++)
  {
    scanf("%lld",&tal[i]);
    while(t>0&&q[t]<tal[i]){ans=max(ans,tal[i]^q[t--]);}
    ans=max(ans,tal[i]^q[t]);q[++t]=tal[i];
  }printf("%lld",ans);
}


#include<bits/stdc++.h>
using namespace std;
int n,m,ans,t,maxn,tal[1010101],zhi[1010101];
int q[1010101<<1];
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
    scanf("%d",&tal[i]);
    while(t>0&&q[t]<tal[i]){ans=max(ans,tal[i]^q[t--]);}
    ans=max(ans,tal[i]^q[t]);q[++t]=tal[i];
  }printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,t,maxn,tal[1010101],zhi[1010101];
long long q[1010101<<1];
int main()
{
  scanf("%lld",&n);
  for(int i=1;i<=n;i++)
  {
    scanf("%lld",&tal[i]);
    while(t>0){
        ans=max(ans,tal[i]^q[t]);
        if(q[t]>tal[i])break;t--;
    }
    q[++t]=tal[i];
  }

  printf("%lld",ans);
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,t,maxn,tal[1010101],zhi[1010101];
long long q[1010101<<1];
int main()
{
  scanf("%lld",&n);
  for(int i=1;i<=n;i++)
  {
    scanf("%lld",&tal[i]);
    while(t>0&&q[t]<tal[i]){ans=max(ans,tal[i]^q[t--]);}
    q[++t]=tal[i];
  }

  printf("%lld",ans);
}


#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,t,maxn,tal[1010101],zhi[1010101];
long long q[1010101<<1];
int main()
{
  scanf("%lld",&n);
  for(int i=1;i<=n;i++)
  {
    scanf("%lld",&tal[i]);
    while(t>0&&q[t]<=tal[i]){ans=max(ans,tal[i]^q[t--]);}
    q[++t]=tal[i];
  }

  printf("%lld",ans);
}


#include<algorithm>
#include<cassert>
#include<complex>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>
#include<string>
#include<vector>
#include<iostream>
#include<cstring>
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define fup FOR
#define fdo FORD
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define siz SZ
#define CLR(x) memset((x), 0, sizeof(x))
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define FI X
#define SE Y
#define SQR(a) ((a)*(a))
#define DEBUG 1
#define debug(x) {if (DEBUG)cerr <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; FORE(it, (x)) cerr <<*it <<", "; cout <<endl; }}
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int>P;
typedef vector<int>VI;
const int INF=1E9+7;
template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
#define MAXN 200007
#define BASE (1<<18)

struct DP {
    int dp[2*BASE];
    bool bit[2*BASE];
    DP(){CLR(dp);}

    void check(int x){
            if(bit[x]) {
                bit[x] = false;
                bit[x+x] = bit[x+x+1] = true;
                dp[x+x] = dp[x+x+1] = dp[x];
            }
    }

    void set(int l, int r, int v, int x = 1, int ll = 1, int rr = BASE) {
        if(r < ll || rr < l) return;
        if(l <= ll && rr <= r) {
            dp[x] = v;
            bit[x] = true;
        } else {
            check(x);
            set(l, r, v, x+x, ll, (ll+rr)/2);
            set(l, r, v, x+x+1, (ll+rr+1)/2, rr);
            //update
        }
    }
    int get(int l, int r, int x = 1, int ll = 1, int rr = BASE) {
        if(r < ll || rr < l) return 0;
        if(l <= ll && rr <= r) {
            return dp[x];
        } else {
            check(x);
            return get(l, r, x+x, ll, (ll+rr)/2) +
            get(l, r, x+x+1, (ll+rr+1)/2, rr);
        }
    }

};

DP dp;
int a[MAXN],n,m;

int main(){
	ios_base::sync_with_stdio(false);
    cout << setprecision(15) << fixed;
	//in
    cin >> n >> m;
    FOR(i,1,2*n) cin >> a[i];
	//sol
    dp.set(1,n,n);
    while(m--) {
        int t, x, y, k;
        cin >> t;
        if(t == 1) {
            cin >> x >> y >> k;
            dp.set(y, y+k-1, x-y);
        } else {
            cin >> x;
            cout << a[x + dp.get(x,x)] << endl;
        }
    }
	//out
	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <complex>
#include <stack>
#include <iomanip>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
#define VAR(v, i) __typeof(i) v = (i)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define fup FOR
#define fdo FORD
#define FORE(i,x) for(__typeof((x).begin()) i=(x).begin();i != (x).end();++i)
#define ALL(x) (x).begin(),(x).end()
#define CLR(x) memset((x),0,sizeof (x))
#define SQR(x) ((x)*(x))
#define X first
#define Y second
#define FI first
#define SE second
#define DEBUG 1
#define SZ(x) ((int)(x).size())
#define siz SZ
#define debug(x) { if (DEBUG) { cerr << #x << " = " << x << endl; } }
#define debugv(x) {  if (DEBUG) { cerr << #x << " = "; FORE(it, (x)) cerr << *it << ", "; cerr << endl; }}
typedef long long int LL;
typedef long double LD;
typedef pair<int, int> P;
typedef vector<int> VI;
const int INF = 1e9 + 7;
template<class C> inline void mini(C& a4, C b4) {a4=min(a4,b4);}
template<class C> inline void maxi(C& a4, C b4) {a4=max(a4,b4);}
#define MAXN 100007

int main(){
    std::ios_base::sync_with_stdio(0);
#ifndef STD
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    	//in

    	//sol

    	//out

    	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <complex>
#include <stack>
#include <iomanip>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
#define VAR(v, i) __typeof(i) v = (i)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define fup FOR
#define fdo FORD
#define FORE(i,x) for(__typeof((x).begin()) i=(x).begin();i != (x).end();++i)
#define ALL(x) (x).begin(),(x).end()
#define CLR(x) memset((x),0,sizeof (x))
#define SQR(x) ((x)*(x))
#define X first
#define Y second
#define FI first
#define SE second
#define DEBUG 1
#define SZ(x) ((int)(x).size())
#define siz SZ
#define debug(x) { if (DEBUG) { cerr << #x << " = " << x << endl; } }
#define debugv(x) {  if (DEBUG) { cerr << #x << " = "; FORE(it, (x)) cerr << *it << ", "; cerr << endl; }}
typedef long long int LL;
typedef long double LD;
typedef pair<int, int> P;
typedef vector<int> VI;
const int INF = 1e9 + 7;
template<class C> inline void mini(C& a4, C b4) {a4=min(a4,b4);}
template<class C> inline void maxi(C& a4, C b4) {a4=max(a4,b4);}
#define MAXN 100007

int n, a[MAXN], pop[MAXN], res;

int main(){
    std::ios_base::sync_with_stdio(0);
    	//in
	cin >> n;
	REP(i,n) cin >> a[i];
    	//sol
	REP(_,2) {
		REP(i,n) {
			pop[i] = i-1;
			while (pop[i] >= 0 && a[pop[i]] < a[i])
				pop[i] = pop[pop[i]];
			if (pop[i] >= 0) maxi(res, a[i]^a[pop[i]]);
		}
		reverse(a,a+n);
	}
    	//out
	cout << res << endl;
    	return 0;
}


//Tapan Sahni
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define LL long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define all(x) x.begin(),x.end()
#define compress(x) {sort(all(x));(x).resize(unique(all(x))-(x).begin());}
template<class T> inline void umax(T &a,T b){if(a<b) a = b ;}
typedef pair<int, int> ii;
typedef pair<LL, LL> PII;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define sz size()
#define pb push_back
#define F first
#define S second
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repv(i,b,a) for(int i=(b);i>=(a);i--)
#define mod 1000000007
#define pb push_back
#define mp make_pair

const int maxn = 100000 + 10;
const int INF  = 1e9 + 7;
//const LL INF = 0x0123456789ABCDEFLL;
int a[maxn];
/*LL rec(int i,int j){
    if(i==j) return 0;
    if(j-i==1){
        return a[i]^a[j];
    }
    LL mid=(i+j)/2;
    LL ans=0;
    ans=max(ans,rec(i,mid));
    ans=max(ans,rec(mid+1,j));
    int i1=mid,i2=mid+1;
    LL m1=a[i1],m2=a[i2];
    while(i1>=i || i2<=j){
        ans=max(ans,m1^m2);
        if(i1==i && i2==j) break;
        if(a[i1]>a[i2]){
            if(i2<j)i2++;
            else i1--;
        }
        else{
            if(i1>0)i1--;
            else i2++;
        }
        m1=max(a[i1],m1);
        m2=max(a[i2],m2);
    }
    return ans;
}*/
stack<int> st;
inline void solve(void){
            int n;
            cin>>n;
            rep(i,0,n)cin>>a[i];
            int ans=0;
            rep(i,0,n){
                if(st.empty())st.push(a[i]);
                ans=max(ans , st.top()^a[i]);
                if(st.top()>a[i]){
                    st.push(a[i]);
                    continue;
                }
                while(st.top()<a[i])st.pop(),ans=max(ans,a[i]^st.top());
                st.push(a[i]);

            }
            cout<<ans;

}
void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
int main(int argc, const char * argv[]){
    //freopen("rmq.in","r",stdin);
    //freopen("rmq.out","w",stdout);
    init();
    solve();
    return 0;
}


//Tapan Sahni
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define LL long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define all(x) x.begin(),x.end()
#define compress(x) {sort(all(x));(x).resize(unique(all(x))-(x).begin());}
template<class T> inline void umax(T &a,T b){if(a<b) a = b ;}
typedef pair<int, int> ii;
typedef pair<LL, LL> PII;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define sz size()
#define pb push_back
#define F first
#define S second
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repv(i,b,a) for(int i=(b);i>=(a);i--)
#define mod 1000000007
#define pb push_back
#define mp make_pair

const int maxn = 100000 + 10;
const int INF  = 1e9 + 7;
//const LL INF = 0x0123456789ABCDEFLL;
LL a[maxn];
LL rec(int i,int j){
    if(i==j) return 0;
    if(j-i==1){
        return a[i]^a[j];
    }
    LL mid=(i+j)/2;
    LL ans=0;
    ans=max(ans,rec(i,mid));
    ans=max(ans,rec(mid+1,j));
    int i1=mid,i2=mid+1;
    LL m1=a[i1],m2=a[i2];
    while(i1>=i || i2<=j){
        ans=max(ans,m1^m2);
        if(i1==i && i2==j) break;
        if(a[i1]>a[i2]){
            if(i2<j)i2++;
            else i1--;
        }
        else{
            if(i1>0)i1--;
            else i2++;
        }
        m1=max(a[i1],m1);
        m2=max(a[i2],m2);
    }
    return ans;
}
inline void solve(void){
            int n;
            cin>>n;
            rep(i,0,n)cin>>a[i];
            LL ans=0;
            rep(i,0,n){
                rep(j,i+1,n){
                    ans=max(a[i]^a[j],ans);
                    if(a[j]>a[i])break;
                }
                int f=0;
                rep(j,i+1,n){
                    ans=max(a[i]^a[j],ans);
                    if(a[j]<a[i])break;
                }
            }
            cout<<ans;

}
void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
int main(int argc, const char * argv[]){
    //freopen("rmq.in","r",stdin);
    //freopen("rmq.out","w",stdout);
    init();
    solve();
    return 0;
}


//Tapan Sahni
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define LL long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define all(x) x.begin(),x.end()
#define compress(x) {sort(all(x));(x).resize(unique(all(x))-(x).begin());}
template<class T> inline void umax(T &a,T b){if(a<b) a = b ;}
typedef pair<int, int> ii;
typedef pair<LL, LL> PII;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define sz size()
#define pb push_back
#define F first
#define S second
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repv(i,b,a) for(int i=(b);i>=(a);i--)
#define mod 1000000007
#define pb push_back
#define mp make_pair

const int maxn = 100000 + 10;
const int INF  = 1e9 + 7;
//const LL INF = 0x0123456789ABCDEFLL;
LL a[maxn];
LL rec(int i,int j){
    if(i==j) return 0;
    if(j-i==1){
        return a[i]^a[j];
    }
    LL mid=(i+j)/2;
    LL ans=0;
    ans=max(ans,rec(i,mid));
    ans=max(ans,rec(mid+1,j));
    int i1=mid,i2=mid+1;
    LL m1=a[i1],m2=a[i2];
    while(i1>=i || i2<=j){
        ans=max(ans,m1^m2);
        if(i1==i && i2==j) break;
        if(a[i1]>a[i2]){
            if(i2<j)i2++;
            else i1--;
        }
        else{
            if(i1>0)i1--;
            else i2++;
        }
        m1=max(a[i1],m1);
        m2=max(a[i2],m2);
    }
    return ans;
}
inline void solve(void){
            int n;
            cin>>n;
            rep(i,0,n)cin>>a[i];
            LL ans=0;
            rep(i,0,n){
                rep(j,i+1,n){
                    ans=max(a[i]^a[j],ans);
                    if(a[j]>a[i])break;
                    if(a[j]>a[j+1])break;
                }
                rep(j,i+1,n){
                    ans=max(a[i]^a[j],ans);
                    if(a[j]<a[i])break;
                    if(a[j]<a[j+1] && j<n-1){
                        ans=max(ans,a[i]^a[j+1]);
                    }
                }
            }
            cout<<ans;

}
void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
int main(int argc, const char * argv[]){
    //freopen("rmq.in","r",stdin);
    //freopen("rmq.out","w",stdout);
    init();
    solve();
    return 0;
}


//Tapan Sahni
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define LL long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define all(x) x.begin(),x.end()
#define compress(x) {sort(all(x));(x).resize(unique(all(x))-(x).begin());}
template<class T> inline void umax(T &a,T b){if(a<b) a = b ;}
typedef pair<int, int> ii;
typedef pair<LL, LL> PII;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define sz size()
#define pb push_back
#define F first
#define S second
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repv(i,b,a) for(int i=(b);i>=(a);i--)
#define mod 1000000007
#define pb push_back
#define mp make_pair

const int maxn = 100000 + 10;
const int INF  = 1e9 + 7;
//const LL INF = 0x0123456789ABCDEFLL;
LL a[maxn];
LL rec(int i,int j){
    if(i==j) return 0;
    if(j-i==1){
        return a[i]^a[j];
    }
    LL mid=(i+j)/2;
    LL ans=0;
    ans=max(ans,rec(i,mid));
    ans=max(ans,rec(mid+1,j));
    int i1=mid,i2=mid+1;
    LL m1=a[i1],m2=a[i2];
    while(i1>=i || i2<=j){
        ans=max(ans,m1^m2);
        if(i1==i && i2==j) break;
        if(a[i1]>a[i2]){
            if(i2<j)i2++;
            else i1--;
        }
        else{
            if(i1>0)i1--;
            else i2++;
        }
        m1=max(a[i1],m1);
        m2=max(a[i2],m2);
    }
    return ans;
}
inline void solve(void){
            int n;
            cin>>n;
            rep(i,0,n)cin>>a[i];
            cout<<rec(0,n-1);
            return;

}
void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
int main(int argc, const char * argv[]){
    //freopen("rmq.in","r",stdin);
    //freopen("rmq.out","w",stdout);
    init();
    solve();
    return 0;
}


//Tapan Sahni
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define LL long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define all(x) x.begin(),x.end()
#define compress(x) {sort(all(x));(x).resize(unique(all(x))-(x).begin());}
template<class T> inline void umax(T &a,T b){if(a<b) a = b ;}
typedef pair<int, int> ii;
typedef pair<LL, LL> PII;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define sz size()
#define pb push_back
#define F first
#define S second
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repv(i,b,a) for(int i=(b);i>=(a);i--)
#define mod 1000000007
#define pb push_back
#define mp make_pair

const int maxn = 100000 + 10;
const int INF  = 1e9 + 7;
//const LL INF = 0x0123456789ABCDEFLL;
int a[maxn];
int rec(int i,int j){
    if(i==j) return 0;
    if(j-i==1){
        return a[i]^a[j];
    }
    int mid=(i+j)/2;
    int ans=0;
    ans=max(ans,rec(i,mid));
    ans=max(ans,rec(mid+1,j));
    int i1=mid,i2=mid+1;
    int m1=a[i1],m2=a[i2];
    while(i1>=i || i2<=j){
        ans=max(ans,m1^m2);
        if(i1==i && i2==j) break;
        if(a[i1]>a[i2]){
            if(i2<j)i2++;
            else i1--;
        }
        else{
            if(i1>0)i1--;
            else i2++;
        }
        m1=max(a[i1],m1);
        m2=max(a[i2],m2);
    }
    return ans;
}
inline void solve(void){
            int n;
            cin>>n;
            rep(i,0,n)cin>>a[i];
            cout<<rec(0,n-1);
            return;

}
void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
int main(int argc, const char * argv[]){
    //freopen("rmq.in","r",stdin);
    //freopen("rmq.out","w",stdout);
    init();
    solve();
    return 0;
}


//Tapan Sahni
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define LL long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define all(x) x.begin(),x.end()
#define compress(x) {sort(all(x));(x).resize(unique(all(x))-(x).begin());}
template<class T> inline void umax(T &a,T b){if(a<b) a = b ;}
typedef pair<int, int> ii;
typedef pair<LL, LL> PII;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define sz size()
#define pb push_back
#define F first
#define S second
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repv(i,b,a) for(int i=(b);i>=(a);i--)
#define mod 1000000007
#define pb push_back
#define mp make_pair

const int maxn = 100000 + 10;
const int INF  = 1e9 + 7;
//const LL INF = 0x0123456789ABCDEFLL;
int a[maxn];
int rec(int i,int j){
    if(i==j) return 0;
    if(j-i==1){
        return a[i]^a[j];
    }
    int mid=(i+j)/2;
    int ans=0;
    ans=max(ans,rec(i,mid));
    ans=max(ans,rec(mid+1,j));
    int i1=mid,i2=mid+1;
    int m1=a[i1],m2=a[i2];
    while(i1>=i || i2<=j){
        ans=max(ans,m1^m2);
        if(i1==i && i2==j) break;
        if(a[i1]>a[i2]){
            if(i2<j)i2++;
            else i1--;
        }
        else{
            if(i1>0)i1--;
            else i2++;
        }
        m1=max(a[i1],m1);
        m2=max(a[i2],m2);
    }
    return ans;
}
stack<int> st;
inline void solve(void){
            int n;
            cin>>n;
            rep(i,0,n)cin>>a[i];
            int ans=0;
            rep(i,0,n){
                if(st.empty()){
                    st.push(a[i]);
                    continue;
                }
                while(st.top()<a[i]){
                    ans=max(ans,a[i]^st.top()),st.pop();
                    if(st.empty()) break;
                }
                if(!st.empty()){
                ans=max(ans , st.top()^a[i]);
                if(st.top()>a[i]){
                    st.push(a[i]);
                    continue;
                }
            }
                st.push(a[i]);
            }
            cout<<ans;

}
void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
int main(int argc, const char * argv[]){
    //freopen("rmq.in","r",stdin);
    //freopen("rmq.out","w",stdout);
    init();
    solve();
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<stack>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=100050;
int n,a[maxn];
int s[maxn],top;
inline int read()
{
	int x=0,t=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*t;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		while(top&&s[top]<a[i]) top--;
		if(top) ans=max(ans,a[i]^s[top]);

		s[++top]=a[i];
	}
	reverse(a+1,a+n+1);
	top=0;
	memset(s,0,sizeof(s));
	for(int i=1;i<=n;i++)
	{
		while(top&&s[top]<a[i]) top--;
		if(top) ans=max(ans,a[i]^s[top]);

		s[++top]=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100010],n,ans;
deque<int> q;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		while(!q.empty()){
			ans=max(ans,q.back()^a[i]);
//		cout<<q.back()<<endl;
			if(a[i]<q.back())break;
			q.pop_back();
		}
		q.push_back(a[i]);
	}
	cout<<ans;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <stack>

#define N (100000 + 5)
#define ll long long

static ll nArray[N];

ll ArrayXor(int num) {
  std::stack<int> mono_stack;
  ll result = 0;
  for (int i = 0; i < num; i++) {
    while (!mono_stack.empty() && nArray[mono_stack.top()] < nArray[i]) {
      mono_stack.pop();
    }

    if (!mono_stack.empty()) {
      result = std::max(result, nArray[mono_stack.top()] ^ nArray[i]);
    }

    mono_stack.push(i);
  }
  return result;
}

void Reverse(int num) {
  for (int i = 0; i < num / 2; i++) {
    ll tmp = nArray[i];
    nArray[i] = nArray[num - i];
    nArray[num - i] = tmp;
  }
}

int main() {
  int num;
  scanf("%d", &num);
  for (int i = 0; i < num; i++) {
    scanf("%lld", &nArray[i]);
  }
  ll result = ArrayXor(num);
  Reverse(num);
  result = std::max(result, ArrayXor(num));
  printf("%lld", result);
  return 0;
}


// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read()
{
    char ch=getchar();ll w=1,s=0;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=(s<<1)+(s<<3)+ch-48;ch=getchar();}
    return s*w;
}
ll b[100001],maxx=0,a[100001],ans;
int main()
{
    ll n=read();
    for(ll i=1;i<=n;i++)
    {
        a[i]=read();
    }
    ll t=1;
    b[t]=a[1];
    for(ll i=2;i<=n;i++)
    {
        while(a[i]>b[t]&&t)
        {
            ans=a[i]^b[t];
            maxx=maxx>ans?maxx:ans;
            t--;
        }
        t++;
        b[t]=a[i];
    }
    t=1;
    b[t]=a[n];
    for(ll i=n-1;i>=1;i--)
    {
        while(a[i]>b[t]&&t)
        {
            ans=a[i]^b[t];
            maxx=maxx>ans?maxx:ans;
            t--;
        }
        t++;
        b[t]=a[i];
    }
    printf("%lld\n",maxx);
}


#include <cstdio>
#include <iostream>
#include <stack>

#define N (100000 + 5)

static int nArray[N];

int ArrayXor(int num) {
  std::stack<int> mono_stack;
  int result = 0;
  for (int i = 0; i < num; i++) {
    while (!mono_stack.empty() && nArray[mono_stack.top()] < nArray[i]) {
      mono_stack.pop();
    }

    if (!mono_stack.empty()) {
      result = std::max(result, nArray[mono_stack.top()] ^ nArray[i]);
    }

    mono_stack.push(i);
  }
  return result;
}

void Reverse(int num) {
  if (num <= 1) {
    return;
  }
  for (int i = 0; i < num / 2; i++) {
    int tmp = nArray[i];
    nArray[i] = nArray[num - i - 1];
    nArray[num - i - 1] = tmp;
  }
}

int main() {
  int num;
  scanf("%d", &num);
  for (int i = 0; i < num; i++) {
    scanf("%d", &nArray[i]);
  }
  int result = ArrayXor(num);
  Reverse(num);
  result = std::max(result, ArrayXor(num));
  printf("%d", result);
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-') f=-1;s=getchar();}
	while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
	return x*f;
}
stack<int>s1;
stack<int>s2;
int a[100005];
int main()
{
	int ans=-1;
	int n=read();
	for(int i=1;i<=n;++i)
	  a[i]=read();
	for(int i=1;i<=n;++i)
	{
		while(!s1.empty()&&s1.top()<a[i])
		  s1.pop();
		if(!s1.empty())
		  ans=max(ans,a[i]^(s1.top()));
		s1.push(a[i]);//或者也可以push(i)，然后每次比较时是比较a[s1.top()]和a[i]
	}
	for(int i=n;i>=1;--i)
	{
		while(!s2.empty()&&s2.top()<a[i])
		  s2.pop();
		if(!s2.empty())
		  ans=max(ans,a[i]^(s2.top()));
		s2.push(a[i]);//或者也可以push(i)，然后每次比较时是比较a[s1.top()]和a[i]
	}
	printf("%d\n",ans);
}


#include<bits/stdc++.h>

using namespace std;

const int kMaxN = 100000 + 5;

int n , ans , a[kMaxN];

inline int read(){
	int s = 0 , w = 1;
	char ch = getchar();
	while((ch < '0') || (ch > '9')){
		if(ch == '-'){
			w = -1;
		}
		ch = getchar();
    }
   	while((ch >= '0') && (ch <= '9')){
   		s = (s << 3) + (s << 1) + ch - '0';
		ch = getchar();
	}
   	return s * w;
}

inline void write(int x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9){
    	write(x / 10);
	}
    putchar(x % 10 + '0');
    return ;
}

int main(){

	n = read();

	stack <int> sta;

	for(int i = 1 ; i <= n ; i++ ){
		a[i] = read();
		while(sta.empty() == false){
			ans = max(ans , a[i] ^ sta.top());
			if(sta.top() > a[i]){
				break;
			}
		}
		sta.push(a[i]);
	}

	cout << ans << endl;

	return 0;
}


#include <cstdio>
#include <stack>
using namespace std;
int ans,n;
stack<int> st;
int main()
{
	int x;
	scanf("%d",&n);
	while (n--)
	{
		scanf("%d",&x);
		while (!st.empty())
		{
			if (ans<st.top()^x)
				ans=st.top()^x;
			if (st.top()>x)
				break;
			else st.pop();
		}
		st.push(x);
	}
	printf("%d",ans);
	return 0;
}


// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
int n,ans;
int a[120000];
int judge(int l,int r)
{
    priority_queue <int> q;
    for(int i=l;i<=r;i++)
    q.push(a[i]);
    int ans=q.top();
    q.pop();
    return ans^q.top();
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
    ans=max(ans,judge(i,j));
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000001],b[1000001];
stack<int>s;
stack<int>ss;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=n+1;
	}
	for(int i=1;i<=n;i++)
	{
		while(!s.empty()&&s.top()<a[i])
		{
			s.pop();
			int r=ss.top();
			ss.pop();
			b[r]=i;
		}
		s.push(a[i]);
		ss.push(i);
	}
	int ans=0;
	/*for(int i=1;i<=n;i++)
	{
		cout<<b[i]<<endl;
	}*/
	for(int i=1;i<=n;i++)
	{
		int j=i+1;
		while(j<=b[i]&&j<=n)
		{
			ans=max(ans,a[i]^a[j]);
			if(a[j]>a[i])break;
			j=b[j];
		}
		if(b[i]<=n)ans=max(ans,a[i]^a[b[i]]);

	}
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
stack<long long> r;
long long ans;
int main()
{
	//“最大”异或“次大”
	int n;
	long long s;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%lld",&s);
		while(!r.empty())
		{
			ans=max(ans,s^r.top());
			if (r.top()>s) break;
			r.pop();
		}
		r.push(s);
	}
	printf("%lld",ans);
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100005],ans;
stack<int>s;
signed main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    a[0]=2147483647;
    s.push(0);
    for(int i=1;i<=n;i++){
        while(a[s.top()]<a[i])s.pop();
        if(s.top())ans=max(ans,a[i]^a[s.top()]);
        s.push(i);
    }
    while(!s.empty())s.pop();
    s.push(0);
    for(int i=n;i>=1;i--){
        while(a[s.top()]<a[i])s.pop();
        if(s.top())ans=max(ans,a[i]^a[s.top()]);
        s.push(i);
    }
    printf("%d",ans);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
stack<int> s;
int r[maxn];
int a[maxn];
int main()
{
    int n,ans;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=n-1;i>=0;i--)
    {
        while(!s.empty()&&a[s.top()]<a[i])//找每个数右边第一个比它大的数的下标
        {
            s.pop();
        }
        if(s.empty())
        {
            r[i]=n;
        }
        else
        {
            r[i]=s.top();
        }
        s.push(i);
    }
    ans=0;
    int t;
    for(int i=0;i<n;i++)
    {
        int j=i+1;
        while(j<n)
        {
            t=a[i]^a[j];
            if(t>ans)
            {
                ans=t;
            }
            if(a[j]>a[i])
            {
                break;
            }
            j=r[j];
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define ld long double
#define ll long long
#define sqr(a) (a)*(a)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define inf (int)1e9
#define pi pair<int,int>
#define y1 fdfs
using namespace std;
const int N=1e5+1;
int a[N],n,st[20][N],lg[N],l,r,ans;
int f(int l,int r)
{
    int x=lg[r-l+1];
    return max(st[x][l],st[x][r-(1<<x)+1]);
}
int main()
{
    /*freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);*/
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
     for(int i=2;i<=n;++i)
        lg[i]=lg[i/2]+1;
    for(int q=0;q<2;++q){
    for(int i=1;i<=n;++i)
        st[0][i]=a[i];
    for(int i=1;i<=lg[n];++i)
    for(int j=1;j+(1<<i)-1<=n;++j)
        st[i][j]=max(st[i-1][j],st[i-1][j+(1<<(i-1))]);
    for(int i=1;i<=n;++i)
    {
        l=i,r=n;
        while(r-l>1)
        {
            int mid=(l+r)>>1;
            if(f(i,mid)<=a[i]) l=mid;
                          else r=mid;
        }
        if(a[l]>a[i]) ans=max(ans,a[l]^a[i]);else
        if(a[r]>a[i]) ans=max(ans,a[r]^a[i]);
    }
    reverse(a+1,a+n+1);
    }
    cout<<ans;
}


#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define ld long double
#define ll long long
#define sqr(a) (a)*(a)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define inf (int)1e9
#define pi pair<int,int>
#define y1 fdfs
using namespace std;
const int N=1e5+1;
int a[N],n,st[20][N],lg[N],l,r,ans;
inline int f(int l,int r)
{
    int x=lg[r-l+1];
    return max(st[x][l],st[x][r-(1<<x)+1]);
}
int main()
{
    /*freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);*/
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
     for(int i=2;i<=n;++i)
        lg[i]=lg[i/2]+1;
    for(int q=0;q<2;++q){
    for(int i=1;i<=n;++i)
        st[0][i]=a[i];
    for(int i=1;i<=lg[n];++i)
    for(int j=1;j+(1<<i)-1<=n;++j)
        st[i][j]=max(st[i-1][j],st[i-1][j+(1<<(i-1))]);
    for(int i=1;i<=n;++i)
    {
        l=i,r=n;
        while(r-l>1)
        {
            int mid=(l+r)>>1;
            if(f(i,mid)<=a[i]) l=mid;
                          else r=mid;
        }
        if(a[l]>a[i]) ans=max(ans,a[l]^a[i]);else
        if(a[r]>a[i]) ans=max(ans,a[r]^a[i]);
    }
    reverse(a+1,a+n+1);
    }
    cout<<ans;
}


#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define ld long double
#define ll long long
#define sqr(a) (a)*(a)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define inf (int)1e9
#define pi pair<int,int>
#define y1 fdfs
using namespace std;
const int N=1e5+1;
int a[N],n,st[20][N],lg[N],l,r,ans;
int f(int l,int r)
{
    int x=lg[r-l+1];
    return max(st[x][l],st[x][r-(1<<x)+1]);
}
int main()
{
    /*freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);*/
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
     for(int i=2;i<=n;++i)
        lg[i]=lg[i/2]+1;
    for(int q=0;q<2;q++){
    for(int i=1;i<=n;i++)
        st[0][i]=a[i];
    for(int i=1;i<=lg[n];++i)
    for(int j=1;j+(1<<i)-1<=n;++j)
        st[i][j]=max(st[i-1][j],st[i-1][j+(1<<(i-1))]);
    for(int i=1;i<=n;i++)
    {
        l=i,r=n;
        while(r-l>1)
        {
            int mid=(l+r)>>1;
            if(f(i,mid)<=a[i]) l=mid;
                          else r=mid;
        }
        if(a[l]>a[i]) ans=max(ans,a[l]^a[i]);else
        if(a[r]>a[i]) ans=max(ans,a[r]^a[i]);
    }
    reverse(a+1,a+n+1);
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define REP(i,a) for (int i = 0; i < a; i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define BUG(x) cout << #x << " = " << x << endl
#define mod 1000000007
#define eps 0.00000001
#define sqr(x) (x) * (x)
#define pb push_back

int n, lis[100005];

int solve(int l, int r) {
    if (r - l < 1) return 0;
    int ind = l;
    FOR (i, l + 1, r) {
        if (lis[ind] < lis[i]) ind = i;
    }
    int cur = 0;
    int ans = 0;
    FOR (i, l, ind - 1) {
        cur = max(cur, lis[i]);
        ans = max(ans, cur ^ lis[ind]);
    }
    cur = 0;
    FOR (i, ind + 1, r) {
        cur = max(cur, lis[i]);
        ans = max(ans, cur ^ lis[ind]);
    }
    ans = max(ans, solve(l, ind - 1));
    ans = max(ans, solve(ind + 1, r));
    return ans;
}

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    REP (i, n) cin >> lis[i];
    cout << solve(0, n - 1);
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define REP(i,a) for (int i = 0; i < a; i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define BUG(x) cout << #x << " = " << x << endl
#define mod 1000000007
#define eps 0.00000001
#define sqr(x) (x) * (x)
#define pb push_back

int n, lis[100005], ans;
stack<int> s;

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    REP (i, n) cin >> lis[i];
    s.push(lis[0]);
    FOR (i, 1, n - 1) {
        while (!s.empty() && s.top() < lis[i]) {
            ans = max(ans, lis[i] ^ s.top());
            s.pop();
        }
        if (!s.empty()) ans = max(ans, lis[i] ^ s.top());
        s.push(lis[i]);
    }
    cout << ans;
}


#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
int chmax(int &x, int y) { if (y > x) { x = y; return 1; } return 0; }
/* =====  SOLUTION START  ===== */
#define maxn 100005
int n;
int stk[maxn], ns;
int ans;
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        while (ns && stk[ns - 1] < x) {
            chmax(ans, x ^ stk[ns - 1]);
            --ns;
        }
        if (ns)
            chmax(ans, x ^ stk[ns - 1]);
        stk[ns++] = x;
    }
    printf("%d\n", ans);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
/* =====  SOLUTION START  ===== */
#define maxn 100005
struct trie_t {
    int sz; // number of leaf
    int c[2];
} arr[maxn * 34];
int na = 2;
int n;
int stk[maxn], ns;
int ans;
void query(int x) {
    int root = 1;
    if (arr[root].sz == 0) return;
    int r = 0;
    for (int i = 31; i >= 0; --i) {
        int bit = (x >> i) & 1;
        if (arr[root].c[!bit] && arr[arr[root].c[!bit]].sz)
            root = arr[root].c[!bit], r |= (1 << i);
        else
            root = arr[root].c[bit];
        assert(arr[root].sz);
    }
    assert(arr[root].sz);
    if (r > ans) ans = r;
}
void add(int x) {
    int root = 1;
    for (int i = 31; i >= 0; --i) {
        ++arr[root].sz;
        int bit = (x >> i) & 1;
        if (!arr[root].c[bit]) arr[root].c[bit] = na++;
        root = arr[root].c[bit];
    }
    ++arr[root].sz;
}
void rem(int x) {
    int root = 1;
    for (int i = 31; i >= 0; --i) {
        --arr[root].sz;
        int bit = (x >> i) & 1;
        root = arr[root].c[bit];
    }
    --arr[root].sz;
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        query(x);
        while (ns && stk[ns - 1] < x) {
            fprintf(stderr, "rem %d\n", stk[ns - 1]);
            rem(stk[--ns]);
            fprintf(stderr, "sz %d\n", arr[1].sz);
        }
        stk[ns++] = x;
        add(x);
        fprintf(stderr, "add %d\n", x);
        fprintf(stderr, "sz %d\n", arr[1].sz);
    }
    printf("%d\n", ans);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
/* =====  SOLUTION START  ===== */
#define maxn 100005
struct trie_t {
    int sz; // number of leaf
    int c[2];
} arr[maxn * 33];
int na = 2;

int n;
int stk[maxn], ns;
int ans;

void query(int x) {
    int root = 1;
    if (arr[root].sz == 0) return;

    int r = 0;
    for (int i = 31; i >= 0; --i) {
        int bit = (x >> i) & 1;

        if (arr[root].c[!bit] && arr[arr[root].c[!bit]].sz)
            root = arr[root].c[!bit], r |= (1 << i);
        else
            root = arr[root].c[bit];
    }
    if (r > ans) ans = r;
}
void add(int x) {
    int root = 1;
    for (int i = 31; i >= 0; --i) {
        ++arr[root].sz;
        int bit = (x >> i) & 1;
        if (!arr[root].c[bit]) arr[root].c[bit] = na++;
        root = arr[root].c[bit];
    }
    ++arr[root].sz;
}
void rem(int x) {
    int root = 1;
    for (int i = 31; i >= 0; --i) {
        --arr[root].sz;
        int bit = (x >> i) & 1;
        root = arr[root].c[bit];
    }
    --arr[root].sz;
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        query(x);

        while (ns && stk[ns - 1] < x) {
            rem(stk[--ns]);
        }
        stk[ns++] = x;
        add(x);
    }
    printf("%d\n", ans);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
int chmax(int &x, int y) { if (y > x) { x = y; return 1; } return 0; }
/* =====  SOLUTION START  ===== */
#define maxn 100005
int n;
int stk[maxn], ns;
int ans;
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        while (ns && stk[ns - 1] < x) {
            chmax(ans, x ^ stk[ns - 1]);
        }
        if (ns)
            chmax(ans, x ^ stk[ns - 1]);
        stk[ns++] = x;
    }
    printf("%d\n", ans);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
/* =====  SOLUTION START  ===== */
#define maxn 100005
struct trie_t {
    int sz; // number of leaf
    int c[2];
} arr[maxn * 33];
int na = 2;

int n;
int stk[maxn], ns;
int ans;

void query(int x) {
    int root = 1;
    if (arr[root].sz == 0) return;

    int r = 0;
    for (int i = 31; i >= 0; --i) {
        int bit = (x >> i) & 1;

        if (arr[root].c[!bit] && arr[arr[root].c[!bit]].sz)
            root = arr[root].c[!bit], r |= (1 << i);
        else
            root = arr[root].c[bit];
    }
    assert(arr[root].sz);
    if (r > ans) ans = r;
}
void add(int x) {
    int root = 1;
    for (int i = 31; i >= 0; --i) {
        ++arr[root].sz;
        int bit = (x >> i) & 1;
        if (!arr[root].c[bit]) arr[root].c[bit] = na++;
        root = arr[root].c[bit];
    }
    ++arr[root].sz;
}
void rem(int x) {
    int root = 1;
    for (int i = 31; i >= 0; --i) {
        --arr[root].sz;
        int bit = (x >> i) & 1;
        root = arr[root].c[bit];
    }
    --arr[root].sz;
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        query(x);

        while (ns && stk[ns - 1] < x) {
            fprintf(stderr, "rem %d\n", stk[ns - 1]);
            rem(stk[--ns]);
            fprintf(stderr, "sz %d\n", arr[1].sz);
        }
        stk[ns++] = x;
        add(x);
        fprintf(stderr, "add %d\n", x);
        fprintf(stderr, "sz %d\n", arr[1].sz);
    }
    printf("%d\n", ans);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
/* =====  SOLUTION START  ===== */
#define maxn 100005
struct trie_t {
    int sz; // number of leaf
    int c[2];
} arr[maxn * 34];
int na = 2;
int n;
int stk[maxn], ns;
int ans;
void query(int x) {
    int root = 1;
    if (arr[root].sz == 0) return;
    int r = 0;
    for (int i = 31; i >= 0; --i) {
        int bit = (x >> i) & 1;
        if (arr[root].c[!bit] && arr[arr[root].c[!bit]].sz)
            root = arr[root].c[!bit], r |= (1 << i);
        else
            root = arr[root].c[bit];
    }
    assert(arr[root].sz);
    if (r > ans) ans = r;
}
void add(int x) {
    int root = 1;
    for (int i = 31; i >= 0; --i) {
        ++arr[root].sz;
        int bit = (x >> i) & 1;
        if (!arr[root].c[bit]) arr[root].c[bit] = na++;
        root = arr[root].c[bit];
    }
    ++arr[root].sz;
}
void rem(int x) {
    int root = 1;
    for (int i = 31; i >= 0; --i) {
        --arr[root].sz;
        int bit = (x >> i) & 1;
        root = arr[root].c[bit];
    }
    --arr[root].sz;
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        query(x);
        while (ns && stk[ns - 1] < x) {
            fprintf(stderr, "rem %d\n", stk[ns - 1]);
            rem(stk[--ns]);
            fprintf(stderr, "sz %d\n", arr[1].sz);
        }
        stk[ns++] = x;
        add(x);
        fprintf(stderr, "add %d\n", x);
        fprintf(stderr, "sz %d\n", arr[1].sz);
    }
    printf("%d\n", ans);
    return 0;
}


#include <bits/stdc++.h>

#define inc(i, a, b) for (int i = a; i <= b; i++)
#define dec(i, a, b) for (int i = a; i >= b; i--)

using namespace std;

typedef long long LL;

const int MAX_N = 1e5 + 5;
const int MAX_M = 2e5 + 5;
const int INF = 0x3f3f3f3f;

int n, s[MAX_N], sp, stk[MAX_N], ans;

void solve() {
	scanf("%d", &n);
	inc(i, 1, n) scanf("%d", s + i);
	inc(i, 1, n) {
		while (sp > 0 && s[stk[sp]] < s[i]) sp--;
		if (sp > 0) ans = max(ans, s[stk[sp]] ^ s[i]);
		stk[++sp] = i;
	}
	sp = 0;
	dec(i, n, 1) {
		while (sp > 0 && s[stk[sp]] < s[i]) sp--;
		if (sp > 0) ans = max(ans, s[stk[sp]] ^ s[i]);
		stk[++sp] = i;
	}
	printf("%d\n", ans);
}

int main() {
	//ios::sync_with_stdio(false);
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	solve();
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<stack>
#define N 100005
using namespace std;
stack<int>s;
int d[N];
int main()
{
	int ans = 0;
	int n;cin>>n;
	for(int i=0;i<n;i++) cin>>d[i];
	for(int i=0;i<n;i++)
	{
		while(!s.empty() && s.top() < d[i])
	    {
	        ans = max(ans, s.top() ^ d[i]);
	        s.pop();
	    }
	    if(!s.empty()) ans = max(ans, d[i] ^ s.top());
	    s.push(d[i]);
	}
	cout<<ans;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<string>
#include<deque>
#include<stack>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    stack<int> s;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int ans = 0;
    s.push(a[1]);
    for(int i=2; i<=n ;i++)
    {
        while(!s.empty() && a[i]>s.top())
        {
            ans = max(ans,a[i]^s.top());
            s.pop();
        }
        if(!s.empty())
            ans = max(ans,a[i]^s.top());
        s.push(a[i]);
    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000+10;
int num[maxn], stk[maxn];
int main()
{
    int n, ans = 0, top = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> num[i];
        while(top && stk[top] < num[i])
            top--;
        if(top)
            ans = max(ans, stk[top]^num[i]);
        stk[++top] = num[i];
    }
    reverse(num, num+n);
    top = 0;
    for(int i = 0; i < n; i++)
    {
        while(top && stk[top] < num[i]) top--;
        if(top)                         ans = max(ans, num[i]^stk[top]);
        stk[++top] = num[i];
    }
    cout << ans << endl;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

const int N = 1e5 + 5;

int n,a[N],s[N];

int solve()
{
    int ret = 0 , top = 0;
    for(int i=0;i<n;i++)
    {
        while(top && a[s[top]] < a[i])
            --top;
        if(top)
            ret = max(ret,a[s[top]] ^ a[i]);
        s[++top] = i;
    }
    return ret;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int ans = solve();
    reverse(a,a+n);
    ans = max(ans,solve());
    printf("%d\n",ans);
    return 0;
}