#include <bits/stdc++.h>
using namespace std;
void solve() {
long long h, n;
if (!(cin >> h >> n)) return;
vector<long long> a(n);
long long min_health = 0;
long long current_pref = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
current_pref += a[i];
min_health = min(min_health, current_pref);
if (h + current_pref <= 0) {
cout << i + 1 << endl;
return;
}
}
long long sum_per_cycle = current_pref;
if (sum_per_cycle >= 0) {
cout << -1 << endl;
return;
}
long long cycles = (h + min_health + abs(sum_per_cycle) - 1) / abs(sum_per_cycle);
long long total_time = cycles * n;
h += cycles * sum_per_cycle;
for (int i = 0; i < n; i++) {
h += a[i];
total_time++;
if (h <= 0) {
cout << total_time << endl;
return;
}
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
solve();
return 0;
}