#include <bits/stdc++.h>
using namespace std;

long long s;
int n, t[21];

bool check(long long x) {
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        res += x / t[i];
    }
    return res >= s;
}

void solve() {
    long long kq;
    long long dau = 1, cuoi = s * 500;
    
    while (dau <= cuoi) {
        long long giua = (dau + cuoi) / 2;
        
        if (check(giua)) {
            kq = giua;
            cuoi = giua - 1;
        } else {
            dau = giua + 1;
        }
    }
    
    cout << kq;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);

    freopen("NAUAN.inp", "r", stdin);
    freopen("NAUAN.out", "w", stdout);
    
    cin >> s >> n;
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
    }
    
    solve();
    return 0;
}
