#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7, M = 2e6;
const long long mod = 1e9 + 7;
inline int read() {
  int ret = 0;
  char ch = getchar();
  bool f = 1;
  for (; !isdigit(ch); ch = getchar()) f ^= !(ch ^ '-');
  for (; isdigit(ch); ch = getchar()) ret = (ret << 1) + (ret << 3) + ch - 48;
  return f ? ret : -ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long ksm(long long a, long long b, long long mod) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long inv2(long long a, long long mod) { return ksm(a, mod - 2, mod); }
long long arr[N];
long long a[N];
long long Min(long long x, long long y) {
  if (x < y) return x;
  return y;
}
int main() {
  long long H;
  long long n;
  scanf("%lld%lld", &H, &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  arr[0] = 0;
  long long minn = 1152921504606846976;
  for (int i = 1; i <= n; i++) {
    arr[i] = arr[i - 1] + a[i];
    minn = Min(arr[i], minn);
  }
  long long l = 0, r = 2000000000000;
  if (H + minn > 0 && arr[n] >= 0) {
    puts("-1");
    return 0;
  }
  long long ans = 0, tmp;
  if (H + minn <= 0) {
    tmp = H;
    for (int i = 1; i <= n; i++) {
      tmp += a[i];
      ans++;
      if (tmp <= 0) break;
    }
    printf("%lld\n", ans);
  } else {
    long long s = (H + minn) / (-arr[n]);
    if ((H + minn) % (-arr[n]) != 0) s++;
    ans += n * s;
    tmp = H += arr[n] * s;
    for (int i = 1; i <= n; i++) {
      tmp += a[i];
      ans++;
      if (tmp <= 0) break;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
