#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double pi = 3.1415926535897932384626;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int maxn = 2e5 + 5;
long long n, m, a[maxn], sum[maxn], maxv;
int main() {
  m = read(), n = read();
  for (long long i = 1; i <= n; ++i) {
    a[i] = read();
    sum[i] = sum[i - 1] - a[i];
    maxv = max(maxv, sum[i]);
  }
  if (sum[n] <= 0 && maxv < m)
    printf("-1\n");
  else if (maxv >= m) {
    for (long long i = 1; i <= n; ++i) {
      if (sum[i] >= m) {
        printf("%lld\n", i);
        break;
      }
    }
  } else {
    long long ans = 1e18;
    for (long long i = 1; i <= n; ++i) {
      ans = min(ans, (m - sum[i] + sum[n] - 1) / sum[n] * n + i);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
