#include <bits/stdc++.h>
using namespace std;
long long arr[2 * 100001];
int main() {
  long long H, n;
  cin >> H >> n;
  long long sum = 0, max_dec = 0, indx = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i + 1];
    sum += arr[i + 1];
    if (sum < max_dec) {
      max_dec = sum;
      indx = i + 1;
    }
  }
  if ((sum < 0) || -1 * max_dec >= H) {
    long long pos_max_dec = -1 * max_dec;
    long long pos_sum = -1 * sum;
    long long ans = 0;
    if (pos_max_dec >= H) {
      long long ache = max_dec;
      while (ache - arr[indx] <= -1 * H) {
        ache = ache - arr[indx];
        indx--;
      }
      cout << ans + indx << endl;
    } else {
      ans = ans + H / pos_sum;
      long long rem = H - ans * pos_sum;
      ans = ans * n;
      while (rem + pos_sum <= pos_max_dec) {
        ans = ans - n;
        rem = rem + pos_sum;
      }
      long long tmp = indx;
      while (indx > 0) {
        if (max_dec - arr[indx] <= -1 * rem) {
          tmp = indx - 1;
        }
        max_dec -= arr[indx];
        indx--;
      }
      cout << endl << ans + tmp << endl;
    }
  } else
    cout << -1 << endl;
  return 0;
}
