#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define sll __int128
#define size(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int long long

mt19937 rnd(time(0));

void dfs(int v, int w, vector<vector<int>> &g, vector<int> &s){
    for (auto to : g[v]){
        dfs(to, min(w, s[v]), g, s);
    }
    s[v] = min(s[v], w);
}

int mx = 0, sm = 1;

void dfs2(int v, vector<vector<int>> &g, vector<int> &s, vector<int> &ch, vector<int> &ans){
    vector<pair<int, int>> a;
    for (auto to : g[v]){
        a.push_back({-s[to], to});
    }
    sort(all(a));
    for (auto [w, to] : a){
        ans[to] = sm - mx; sm++;
        dfs2(to, g, s, ch, ans);
        ch[v] += ch[to];
    }
    mx = max(mx, ch[v]);
}

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

signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int ttt = 1;
    //cin >> ttt;
    while (ttt--){
        solve();
    }
}
