#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int h, n;
  cin >> h >> n;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long int> pref(n);
  pref[0] = a[0];
  for (int i = 1; i < n; i++) {
    pref[i] = pref[i - 1] + a[i];
  }
  for (int i = 0; i < n; i++) {
    if (-pref[i] >= h) {
      cout << i + 1;
      return;
    }
  }
  long long int val = pref[n - 1];
  if (val >= 0) {
    cout << -1;
    return;
  }
  long long int mn = 1e18;
  for (int i = 0; i < n; i++) {
    long long int val2 = h + pref[i];
    long long int cnt = (val2 + abs(val) - 1) / abs(val);
    mn = min(mn, cnt * n + i + 1);
  }
  cout << mn;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test_cases;
  test_cases = 1;
  while (test_cases--) {
    solve();
    cout << "\n";
  }
  return 0;
}
