#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<random>
#include<chrono>
#include<set>
#include<deque>
#include <array>
//define int long long
#define ll long long
#define ld long double
using namespace std;
#pragma GCC optimize("O3, unroll-loops")
#pragma GCC target("avx2")
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> v(m);
	for (int i = 0; i < m; i++) {
		cin >> v[i];
	}
	cout << (n - 1) * v[0] + (m - n + 1) % 2 * v[0];
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
	}
}
