#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int64_t n, m;
	cin >> n >> m;
	vector<int64_t> a(m);
	for (int64_t i = 0; i < m; ++i) {
		cin >> a[i];
	}
	if (m <= n) {
		cout << m * a[0];
	}
	else {
		cout << (n - ((m - n) % 2)) * a[0];
	}
	return 0;
}