#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long h, n;
  cin >> h >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i] *= -1;
  }
  long long x = h;
  long long b[n];
  partial_sum(a, a + n, b);
  long long xx = *max_element(b, b + n);
  long long i;
  for (i = 0; i < n; i++) {
    if (x - b[i] <= 0) break;
  }
  if (i != n) {
    cout << i + 1 << endl;
    return 0;
  }
  if (b[n - 1] <= 0)
    cout << -1 << endl;
  else {
    long long temp = ((h - xx) / b[n - 1]);
    long long ans = temp * n;
    long long i = 0, cnt = 0;
    h -= b[n - 1] * temp;
    while (1) {
      cnt++;
      if (h - a[i] <= 0) break;
      h -= a[i];
      i++;
      if (i == n) i = 0;
    }
    cout << ans + cnt << endl;
  }
}
