#include <bits/stdc++.h>
using namespace std;
long long h, n, a[200005], sum[200005];
int main() {
  scanf("%lld %lld", &h, &n);
  long long ans = 1;
  int f = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = a[i] + sum[i - 1];
    if (h + sum[i] <= 0 && !f) f = 1, ans = i;
  }
  if (f)
    printf("%lld\n", ans);
  else if (sum[n] >= 0)
    printf("-1\n");
  else {
    ans = 1LL << 60;
    for (int i = 1; i <= n; i++) {
      long long t = ceil(1.0 * (h + sum[i]) / (-sum[n]));
      if (t * sum[n] + h <= 0)
        ans = min(ans, t * n);
      else if (t * sum[n] + sum[i] + h <= 0)
        ans = min(ans, t * n + i);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
