#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;
#define all(x) x.begin(),x.end()
#pragma GCC optimize("Ofast")

template<typename T>
void input(vector<T>& arr, size_t size) {
	arr.resize(size);
	for (T& i : arr) {
		cin >> i;
	}
}
template<typename T>
void print(vector<T>& arr) {
	for (T& i : arr) {
		cout << i << ' ';
	}
	cout << '\n';
}

void solve() {
	int n, m;
	cin >> n >> m;
	vector<ll> x(m);
	ll ans = 0, c = 0;
	for (ll i = 0; i < m; i++)
	{
		cin >> x[i];
		if (i >= n - 1) {
			c = x[i] - c;
		}
		else {
			ans += x[i];
		}
	}
	cout << ans + c;
}

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif // _DEBUG
	ios::sync_with_stdio(0);
	cin.tie(0);
	int tt = 1;
#ifdef _DEBUG
	cin >> tt;
#endif // _DEBUG
	while (tt--)
	{
		solve();
#ifdef _DEBUG
		cout << "\n================\n";
#endif // _DEBUG
	}
}