#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
long long a[maxn], sum[maxn];
long long Min = 1e18, h;
int n;
bool check(long long x) {
  if (h + (x - 1) * sum[n] <= abs(Min)) {
    return true;
  } else {
    return false;
  }
}
int main() {
  scanf("%lld%d", &h, &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = sum[i - 1] + a[i];
    Min = min(sum[i], Min);
  }
  long long v = h, flag = 1, pos = 1;
  if (sum[n] >= 0) {
    for (int i = 1; i <= n; i++) {
      v += a[i];
      if (v <= 0) {
        pos = i;
        break;
      }
    }
    if (v > 0) {
      flag = 0;
    }
    if (!flag) {
      printf("-1\n");
      return 0;
    } else {
      printf("%d\n", pos);
      return 0;
    }
  }
  long long l = 0, r = h / (sum[n] * (-1)) + 2;
  while ((r - l) > 1) {
    long long mid = (l + r) / 2;
    if (check(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  long long ans = (r - 1) * n;
  v = h + (r - 1) * sum[n];
  for (int i = 1; i <= n; i++) {
    v += a[i];
    ans++;
    if (v <= 0) {
      break;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
