#include <bits/stdc++.h>
using namespace std;
long long h, n, a[2 * 111111], mn = 2 * 111111;
long long p[2 * 111111];
int main() {
  cin >> h >> n;
  mn = mn * mn * mn * mn;
  p[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p[i] = p[i - 1] + a[i];
  }
  if (p[n] >= 0) {
    for (int i = 1; i <= n; i++) {
      if (h + p[i] <= 0) {
        cout << i << endl;
        return 0;
      }
    }
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    long long cur = max(0ll, h + p[i]);
    cur /= abs(p[n]);
    while (h + p[i] + p[n] * cur > 0) {
      cur++;
    }
    mn = min(mn, i + n * cur);
  }
  cout << mn;
  return 0;
}
