#include <bits/stdc++.h>
using namespace std;
long long min(long long x, long long y) {
  if (x >= y)
    return y;
  else
    return x;
}
int main() {
  long long minn = 12222222;
  long long h, n;
  cin >> h >> n;
  long long a[n];
  long long sum = 0;
  long long tim = 0;
  for (int i = 0; i < n; i++) cin >> a[i], sum = sum + a[i];
  for (int i = 1; i < n; i++) a[i] = a[i] + a[i - 1];
  for (int i = 0; i < n; i++) minn = min(a[i], minn);
  if (sum >= 0 && (h + minn) > 0) {
    cout << "-1" << endl;
    return 0;
  } else {
    long long re = h + minn;
    if (re < 0) re = 0;
    long long c = abs(ceil(re / (double)(abs(sum))));
    h = h + c * sum;
    for (int i = 0; i < n; i++) {
      if ((h + a[i]) <= 0) {
        tim = tim + 1 + i;
        break;
      }
    }
    tim = tim + c * n;
    cout << tim << endl;
  }
}
