#include <iostream>

using namespace std;


int _max = -99999;


long long Suma (int p, int z, int x[200000]) {
	
		if (p==z) {
			 //_max = max (_max, s);	
			return x[p];
		}
		else {
			int a=x[p]-x[z];
			int b=x[z]-x[p];
			int tmp1=x[p];
			int tmp2=x[z];
			
			x[z]=b;
			x[p]=0;
			int u1=Suma (p + 1, z,x);
			x[p]=a;
			x[z]=0;
			int u2=Suma (p, z - 1, x);
			x[p]=tmp1;
			x[z]=tmp2;
			
			return max(u1,u2);
			
		}
/*				
				return max (x[p] - x[z] + Suma (p, z-1, x[p], xz) - xp + xz,
							 		  -x[p] + x[z] + Suma (p+1, z, xp, x[z]) + xp - xz);		
*/							 		  
/*		
			return max (x[p] - x[z] + Suma (p, z-1, x[p]) + temp,
						      x[z] - x[p] - Suma (p + 1, z, x[z]) + temp);
*/						      
}

int main () 
{
	int x[200000];
	int i,n,k;
	cin >> n >> k;
	for(i=0;i<n;i++)
	cin >> x[i];
	
	cout << Suma (0,n-1,x);	
	//cout << _max;
	
	
}