#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long h, n;
  while (cin >> h >> n) {
    long long sum = 0, a[n + 1], div, cnt = 0, hi = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
      hi = min(hi, sum);
    }
    if (sum >= 0) {
      for (int i = 0; i < n; i++) {
        if (h > 0) {
          h += a[i];
          cnt++;
        } else
          break;
      }
      if (h <= 0)
        cout << cnt << endl;
      else
        cout << "-1" << endl;
    } else {
      if (h + hi <= 0) {
        while (h > 0) {
          for (int i = 0; i < n; i++) {
            if (h > 0) {
              h += a[i];
              cnt++;
            } else
              break;
          }
        }
        cout << cnt << endl;
      } else {
        div = (h + hi) / (-1 * sum);
        cnt = div * n;
        h += (div * sum);
        while (h > 0) {
          for (int i = 0; i < n; i++) {
            if (h > 0) {
              h += a[i];
              cnt++;
            } else
              break;
          }
        }
        cout << cnt << endl;
      }
    }
  }
}
