/*input
3
-10 5 -4
*/
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

/** Interface */

inline int readChar();
template <class T = int> inline T readInt();

/** Read */

static const int buf_size = 4096;

inline int getChar() {
	static char buf[buf_size];
	static int len = 0, pos = 0;
	if (pos == len)
		pos = 0, len = fread(buf, 1, buf_size, stdin);
	if (pos == len)
		return -1;
	return buf[pos++];
}

inline ll readInt() {
	int c = getChar();
	if (c != '-')
	{
		ll x = 0;
		if ('0' <= c && c <= '9')
		{
			x = x * 10 + c - '0', c = getChar();
			if ('0' <= c && c <= '9')
			{
				x = x * 10 + c - '0', c = getChar();
				if ('0' <= c && c <= '9')
				{
					x = x * 10 + c - '0', c = getChar();
					if ('0' <= c && c <= '9')
					{
						x = x * 10 + c - '0', c = getChar();
						if ('0' <= c && c <= '9')
						{
							x = x * 10 + c - '0', c = getChar();
							if ('0' <= c && c <= '9')
							{
								x = x * 10 + c - '0', c = getChar();
								if ('0' <= c && c <= '9')
								{
									x = x * 10 + c - '0', c = getChar();
									if ('0' <= c && c <= '9')
									{
										x = x * 10 + c - '0', c = getChar();
										if ('0' <= c && c <= '9')
										{
											x = x * 10 + c - '0', c = getChar();
											if ('0' <= c && c <= '9')
											{
												x = x * 10 + c - '0', c = getChar();
												if ('0' <= c && c <= '9')
												{
													x = x * 10 + c - '0', c = getChar();
													if ('0' <= c && c <= '9')
													{
														x = x * 10 + c - '0', c = getChar();
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		return x;
	}
	else
	{
		int c = getChar();
		ll x = 0;
		if ('0' <= c && c <= '9')
		{
			x = x * 10 + c - '0', c = getChar();
			if ('0' <= c && c <= '9')
			{
				x = x * 10 + c - '0', c = getChar();
				if ('0' <= c && c <= '9')
				{
					x = x * 10 + c - '0', c = getChar();
					if ('0' <= c && c <= '9')
					{
						x = x * 10 + c - '0', c = getChar();
						if ('0' <= c && c <= '9')
						{
							x = x * 10 + c - '0', c = getChar();
							if ('0' <= c && c <= '9')
							{
								x = x * 10 + c - '0', c = getChar();
								if ('0' <= c && c <= '9')
								{
									x = x * 10 + c - '0', c = getChar();
									if ('0' <= c && c <= '9')
									{
										x = x * 10 + c - '0', c = getChar();
										if ('0' <= c && c <= '9')
										{
											x = x * 10 + c - '0', c = getChar();
											if ('0' <= c && c <= '9')
											{
												x = x * 10 + c - '0', c = getChar();
												if ('0' <= c && c <= '9')
												{
													x = x * 10 + c - '0', c = getChar();
													if ('0' <= c && c <= '9')
													{
														x = x * 10 + c - '0', c = getChar();
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		return -x;
	}
}
int main()
{
	ll N, x, y, a, b, c;
	N = readInt();
	a = readInt();
	b = -1e15;
	y = a;
	for (int i = 2; i <= N; i++)
	{
		x = readInt();
		ll c = max(a, b);
		b = -x + max(a - 2 * y, b + 2 * y);
		a = x + c;
		y = x;
	}
	printf("%lld\n", max(a, b));
}

Measured memory_bytes: 256