#include <bits/stdc++.h>
using namespace std;
int main() {
  long long h;
  long n;
  cin >> h >> n;
  vector<long> hit(n);
  for (auto& i : hit) {
    cin >> i;
  }
  long long hit_max = 0;
  long long hit_round = 0;
  for (auto i : hit) {
    hit_round += i;
    hit_max = min(hit_round, hit_max);
  }
  if (hit_max >= 0)
    cout << -1;
  else {
    long long temp = h;
    temp += hit_max;
    if (temp <= 0)
      temp = 0;
    else {
      if (hit_round < -1 && temp < abs(hit_round)) {
        long long trunc = (abs(hit_round) + 1) / 2;
        temp += trunc;
      }
    }
    long long round = 0;
    if (hit_round != 0) round = temp / abs(hit_round);
    if (abs(hit_round) * round < h + hit_max) round++;
    h += round * hit_round;
    long long ans = -1;
    for (long i = 0; i < n; i++) {
      h += hit[i];
      if (h <= 0) {
        ans = i;
        break;
      }
    }
    if (ans > -1)
      cout << ans + 1 + n * round;
    else
      cout << -1;
  }
  return 0;
}
