#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int dp[100010]; int a[100010]; int main(){ int c, n; cin >> c >> n; dp[0] = 0; for (int i = 1; i <= c; i++) { dp[i] = 1000000007; } for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = a[i]; j <= c; j++) { dp[j] = min(dp[j], dp[j - a[i]] + 1); } } if (dp[c] == 1000000007)cout << -1 << endl; else cout << dp[c] << endl; }