//#define _GLIBCXX_DEBUG
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")

#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using ll = long long;
#define int ll
using namespace std;
//using namespace __gnu_pbds;
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
//mt19937 mt(52);
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(auto &el : a) cin >> el;
    if(n <= m)cout << (n-1)*a[0]+((m-n+1)&1)*a[0]; else cout << m*a[0];
}


signed main(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    bool cfmode = (42);
    if(cfmode){
        int t;
        cin >> t;
        while(t--){
            solve();
            cout << '\n';
        }
    } else solve();
}