static long function(long i, long j){
		if(mem[(int)i][(int)j]>0)return mem[(int)i][(int)j];
		if(i==n&&j==1)return an1;
		if(i<j){
			long max = 0; 
			for (long k = i; k < j; k++) 
				max = Math.max(max, function(i, k) + function(k+1, j));
			return mem[(int)i][(int)j] = max;
		}
		else{
			long num = 0, num1 = 0; 
			if(i<n)
				for (long k = i+1; k <= n; k++)
					num = Math.max(function(k,1) + function(k,j), num);
			else num = 0;
			if(j > 0)
				for (long k = 1; k < j; k++)
					num1 = Math.max(function(i,k) + function(n,k), num1);
			else num1 = 0;
			return mem[(int)i][(int)j] = num + num1;
		}
	}