Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips:

Vladik is at initial train station, and now n people (including Vladik) want to get on the train. They are already lined up in some order, and for each of them the city code ai is known (the code of the city in which they are going to).

Train chief selects some number of disjoint segments of the original sequence of people (covering entire sequence by segments is not necessary). People who are in the same segment will be in the same train carriage. The segments are selected in such way that if at least one person travels to the city x, then all people who are going to city x should be in the same railway carriage. This means that they can’t belong to different segments. Note, that all people who travel to the city x, either go to it and in the same railway carriage, or do not go anywhere at all.

Comfort of a train trip with people on segment from position l to position r is equal to XOR of all distinct codes of cities for people on the segment from position l to position r. XOR operation also known as exclusive OR.

Total comfort of a train trip is equal to sum of comfort for each segment.

Help Vladik to know maximal possible total comfort.

Input

First line contains single integer n (1 ≤ n ≤ 5000) — number of people.

Second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 5000), where ai denotes code of the city to which i-th person is going.

Output

The output should contain a single integer — maximal possible total comfort.

Examples

Input

6
4 4 2 5 2 3


Output

14


Input

9
5 1 3 1 5 2 4 2 5


Output

9

Note

In the first test case best partition into segments is: [4, 4] [2, 5, 2] [3], answer is calculated as follows: 4 + (2 xor 5) + 3 = 4 + 7 + 3 = 14

In the second test case best partition into segments is: 5 1 [3] 1 5 [2, 4, 2] 5, answer calculated as follows: 3 + (2 xor 4) = 3 + 6 = 9.
	// Code Author: Rutul Patel
import java.io.*;
	import java.math.BigInteger;
	import java.math.RoundingMode;
	import java.text.DecimalFormat;
	import java.util.*;
	
public class Main {
	
		static double eps=(double)1e-6;
		static long mod=(int)1e9+6;
		
		public static void main(String args[]) throws IOException{
			InputReader sc = new InputReader(System.in);
			OutputStream outputStream = System.out;
			PrintWriter out = new PrintWriter(outputStream);
			//-------------------------------------
			
			int n=sc.nextInt();
			
			int[] arr=new int[n];
			int[] dp=new int[n];
			int[] st=new int[5001];
			int[] end=new int[5001];
			Arrays.fill(st,n+1);
			for(int i=0;i<n;i++)
			{
				arr[i]=sc.nextInt();
				st[arr[i]]=Math.min(st[arr[i]],i);
				end[arr[i]]=Math.max(end[arr[i]],i);
			}
			
			/*for(int i=0;i<6;i++)
			{
				out.println(st[i]+" "+end[i]);
			}*/
			for(int i=0;i<n;i++)
			{
				int mins=Integer.MAX_VALUE;
				int maxe=Integer.MIN_VALUE;
				int xor=0;
				int[] visited=new int[5001];
				boolean flag=false;
				for(int j=i;j>=0;j--)
				{
					if(visited[arr[j]]==0)
						xor=xor^arr[j];
					visited[arr[j]]=1;
					mins=Math.min(mins,st[arr[j]]);
					maxe=Math.max(maxe,end[arr[j]]);
					//out.println(mins+" "+maxe);
					if(maxe>i)
						break;
					else
					{
						if(mins<j)
							continue;
						else
						{
							//out.println("***");
							flag=true;
							if(j==0)
								dp[i]=Math.max(dp[i],xor);
							else
								dp[i]=Math.max(dp[i],dp[j-1]+xor);
						}
					}
				}
				if(!flag&&i!=0)
					dp[i]=dp[i-1];
				if(i!=0)
					dp[i]=Math.max(dp[i],dp[i-1]);
			}
			
			/*for(int i=0;i<n;i++)
			{
				out.print(dp[i]+" ");
			}*/
			out.println(dp[n-1]);
			//-------------------------------------
			out.close();
		}
		
		
		static class Pair implements Comparable<Pair> {
			int a, b;

			Pair(int a, int b) {
				this.a = a;
				this.b = b;
			}

			public int compareTo(Pair o) {
				// TODO Auto-generated method stub
				if (this.a != o.a)
					return Integer.compare(this.a, o.a);
				else
					return Integer.compare(this.b, o.b);
				//return 0;
			}

			public boolean equals(Object o) {
				if (o instanceof Pair) {
					Pair p = (Pair) o;
					return p.a == a && p.b == b;
				}
				return false;
			}

			public int hashCode() {
				return new Integer(a).hashCode() * 31 + new Integer(b).hashCode();
			}

			public String toString() {
				return a + " " + b;
			}
		}
		
		static int[] sieve(int n,int[] arr)
		{
			for(int i=2;i*i<=n;i++)
			{
				if(arr[i]==0)
				{
					for(int j=i*2;j<=n;j+=i)
						arr[j]=1;
				}
			}
			return arr;
		}
		
		static boolean isPal(String s)
		{
			for(int i=0, j=s.length()-1;i<=j;i++,j--)
			{
				if(s.charAt(i)!=s.charAt(j)) return false;
			}
			return true;
		}
		public static String rev(String s)
		{
			StringBuilder sb=new StringBuilder(s);
			sb.reverse();
			return sb.toString();
		}
		    
		static long lcm(long a, long b)
		{
		    return a * (b / gcd(a, b));
		}
		
		static long gcd(long a, long b)
		{
		    while (b > 0)
		    {
		        long temp = b;
		        b = a % b; // % is remainder
		        a = temp;
		    }
		    return a;
		}
		static long modulo(long a,long b,long c) {
			long x=1;
			long y=a;
			while(b > 0){
				if(b%2 == 1){
					x=(x*y)%c;
				}
				y = (y*y)%c; // squaring the base
				b /= 2;
			}
			return  x%c;
		}
		public static void debug(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}
		
		static long sort(int a[]) {
			int n = a.length;
			int b[] = new int[n];
			return mergeSort(a, b, 0, n - 1);
		}

		static long mergeSort(int a[], int b[], long left, long right) {
			long c = 0;
			if (left < right) {
				long mid = left + (right - left) / 2;
				c = mergeSort(a, b, left, mid);
				c += mergeSort(a, b, mid + 1, right);
				c += merge(a, b, left, mid + 1, right);
			}
			return c;
		}

		static long merge(int a[], int b[], long left, long mid, long right) {
			long c = 0;
			int i = (int) left;
			int j = (int) mid;
			int k = (int) left;
			while (i <= (int) mid - 1 && j <= (int) right) {
				if (a[i] <= a[j]) {
					b[k++] = a[i++];
				} else {
					b[k++] = a[j++];
					c += mid - i;
				}
			}
			while (i <= (int) mid - 1)
				b[k++] = a[i++];
			while (j <= (int) right)
				b[k++] = a[j++];
			for (i = (int) left; i <= (int) right; i++)
				a[i] = b[i];
			return c;
		}  
		
	
		static class InputReader {
    		public BufferedReader reader;
    		public StringTokenizer tokenizer;
     
    		public InputReader(InputStream inputstream) {
    			reader = new BufferedReader(new InputStreamReader(inputstream));
    			tokenizer = null;
    		}
     
    		public String nextLine(){
    			String fullLine=null;
    			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
    				try {
    					fullLine=reader.readLine();
    				} catch (IOException e) {
    					throw new RuntimeException(e);
    				}
    				return fullLine;
    			}
    			return fullLine;
    		}
    		public String next() {
    			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
    				try {
    					tokenizer = new StringTokenizer(reader.readLine());
    				} catch (IOException e) {
    					throw new RuntimeException(e);
    				}
    			}
    			return tokenizer.nextToken();
    		}
    		public long nextLong() {
    			return Long.parseLong(next());
    		}
    		public int nextInt() {
    			return Integer.parseInt(next());
    		}
    	}
    	
    }