#include <bits/stdc++.h>
using namespace std;
int n;
long long a[202020], H;
long long mn, sum, ans;
int main() {
  cin >> H >> n;
  long long h = H;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum += a[i];
    h += a[i];
    if (h <= 0) {
      cout << i << endl;
      return 0;
    }
    mn = min(mn, sum);
  }
  if (sum >= 0) {
    cout << -1 << endl;
    return 0;
  }
  sum *= -1;
  mn *= -1;
  long long low = 0, hi = H / sum + 1, ans = 0, mid;
  while (low <= hi) {
    mid = (low + hi) / 2;
    if (H - mid * sum <= mn) {
      hi = mid - 1;
      ans = mid;
    } else
      low = mid + 1;
  }
  H -= ans * sum;
  ans = ans * n;
  for (int i = 1; i <= n; ++i) {
    H += a[i];
    ans++;
    if (H <= 0) {
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}
