#include <bits/stdc++.h>
using namespace std;
int main() {
  long long h, n, r;
  cin >> h >> n;
  long long a[n], i, sum = 0, min = 10000000000000000, c = 0, x = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (sum <= min) min = sum;
  }
  if (h + min > 0 && sum >= 0)
    cout << "-1";
  else {
    if (h + min <= 0)
      r = 0;
    else if ((h + min) % (-1 * sum) == 0)
      r = (h + min) / (-1 * sum);
    else
      r = (h + min) / (-1 * sum) + 1;
    long long s = h - (r * -1 * sum);
    for (i = 0; i < n; i++) {
      x += a[i];
      if (x <= -s) break;
    }
    cout << r * n + i + 1;
  }
}
