#include <bits/stdc++.h>
using namespace std;
long long M, n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long ttttt = 1;
  while (ttttt--) {
    cin >> M >> n;
    long long a[n], ans[n];
    cin >> a[0];
    long long ok = -1;
    if (a[0] <= M * -1) ok = 1;
    for (long long i = 1; i < n; i++) {
      cin >> a[i], a[i] += a[i - 1];
      if (a[i] <= M * -1 && ok == -1) ok = i + 1;
    }
    if (ok != -1) {
      cout << ok;
      cout << '\n';
      return 0;
    }
    if (a[n - 1] >= 0) {
      cout << -1;
      cout << '\n';
      return 0;
    }
    for (long long i = 0; i < n; i++) {
      long long x = M + a[i];
      x = ceil(x / (a[n - 1] * -1.0));
      ans[i] = x * n + i + 1;
    }
    for (long long i = 0; i < n; i++) ans[0] = min(ans[0], ans[i]);
    cout << ans[0];
    cout << '\n';
    return 0;
  }
  return 0;
}
