#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];
  long long b[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  b[0] = a[0];
  for (long long i = 1; i < n; i++) b[i] = a[i] + b[i - 1];
  long long val = h;
  for (long long i = 0; i < n; i++) {
    val += a[i];
    if (val <= 0) {
      cout << i + 1;
      return 0;
    }
  }
  if (b[n - 1] >= 0) {
    cout << -1;
    return 0;
  }
  long long mn = *min_element(b, b + n);
  long long l = abs(b[n - 1]);
  long long c = (h - abs(mn)) / l;
  long long ans = c * 1ll * n;
  h -= c * l;
  c = h;
  if (c == 0) {
    cout << ans << "\n";
    return 0;
  }
  for (long long i = 0; i < 2 * n; i++) {
    ans++;
    c += a[i % n];
    if (c <= 0) {
      cout << ans;
      return 0;
    }
  }
  cout << ans;
}
