#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using ill = long long;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ill n, m;
    cin >> n >> m;
    vector<ill> a(m);
    for (auto &i : a)
        cin >> i;

    int ans = 0;
    for (int b = 0; b < (1 << m); b++) {
        vector<int> d = {0, 0};
        for (int j = 0; j < m; j++) {
            int x = (b >> j) % 2;
            d[x] = a[j] - d[x];
        }
        ans = max(ans, d[0] + d[1]);
    }
    cout << ans;
    return 0;
}