#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
long long H, n;
long long d[200010];
long long sd[200010];
int main() {
  cin >> H >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld", d + i);
  }
  sd[0] = d[0];
  long long delmax = d[0];
  for (int i = 1; i < n; i++) {
    sd[i] = sd[i - 1] + d[i];
    delmax = min(delmax, sd[i]);
  }
  if (sd[n - 1] >= 0 && H + delmax > 0) {
    cout << -1 << endl;
    return 0;
  }
  if (H + delmax <= 0) {
    for (int i = 0; i < n; i++) {
      if (H + sd[i] <= 0) {
        cout << i + 1 << endl;
        return 0;
      }
    }
  }
  long long Hpleft = H + delmax;
  long long round = Hpleft / abs(sd[n - 1]);
  if (Hpleft % abs(sd[n - 1]) != 0) round++;
  Hpleft = H + round * sd[n - 1];
  for (int i = 0; i < n; i++) {
    if (Hpleft + sd[i] <= 0) {
      cout << n * round + i + 1 << endl;
      return 0;
    }
  }
  return 0;
}
