#include <bits/stdc++.h>

#define int long long
using namespace std;

const int INF = 2e16;
vector<int> arr;
vector<int> used;
int ans = 0;

void rec(int i) {
    if (i == arr.size()) {
        int sm = used[0] + used[1];
        ans = max(ans, sm);
        return;
    }
    int p = used[0];
    used[0] = x[i] - used[0];
    rec(i + 1);
    used[0] = p;
    int p1 = used[1];
    used[1] = x[i] - used[1];
    rec(i + 1);
    used[1] = p;
}

signed main() {
    int n, m;
    cin >> n >> m;
    arr.resize(m);
    used.resize(n);
    for (int i = 0; i < m; i++) {
        cin >> arr[i];
    }
    if (n == 2) {
        rec(0);
    }
    cout << ans;
}