//YOUTUBE:youtube.com/channel/UCctCQUpRrxYnCBT7Yh2TuAA
//soicodoc10tin
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define reset(x) memset(x, 0,sizeof(x))
#define Rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define For(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define Ford(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define PB push_back
#define mp make_pair
#define F first
#define S second
#define maxn 1000006
#define MOD 1000000007
#define remain(x) if (x > MOD) x -= MOD
#define pii pair<int, int>
#define bit(x, i) (((x) >> (i)) & 1)
#define LG 30
#define Task "a"
#define int long long
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[] = {0 , -1 , 1 , 0};
int dy[] = {-1 , 0 , 0 , 1};
int n , a[maxn] , dp[maxn][2];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen(Task".inp" , "r")){
freopen(Task".inp" , "r" , stdin);
freopen(Task".out" , "w" , stdout);
}
cin >> n;
For(i , 1 , n) cin >> a[i];
dp[1][0] = 0;
dp[1][1] = a[1];
For(i , 2 , n){
dp[i][0] = max(dp[i - 1][1] - a[i] , dp[i - 1][0]);
dp[i][1] = max(dp[i - 1][0] + a[i] , dp[i - 1][1]);
}
cout << max(dp[n][0] , dp[n][1]);
return 0;
}
Ly9ZT1VUVUJFOnlvdXR1YmUuY29tL2NoYW5uZWwvVUNjdENRVXBScnhZbkNCVDdZaDJUdUFBCi8vc29pY29kb2MxMHRpbgojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBzeih4KSBpbnQoeC5zaXplKCkpCiNkZWZpbmUgcmVzZXQoeCkgbWVtc2V0KHgsIDAsc2l6ZW9mKHgpKQojZGVmaW5lIFJlcChpLG4pIGZvcihpbnQgKGkpPTA7KGkpPChpbnQpKG4pOysrKGkpK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