#include <bits/stdc++.h>
using namespace std;
long long mnval, mnindx;
long long ans = 0, n, m;
long long ara[500005];
int main() {
  long long i, j, a, b, x, y;
  string s, t;
  cin >> m >> n;
  long long sum = 0;
  for (i = 1; i <= n; i++) {
    cin >> ara[i];
    sum -= ara[i];
    if (sum > mnval) {
      mnval = sum;
      mnindx = i;
      if (sum >= m && ans == 0) {
        ans = i;
      }
    }
  }
  if (ans) {
    cout << ans << endl;
    return 0;
  } else if (sum <= 0) {
    cout << "-1" << endl;
    return 0;
  }
  for (j = 1; j <= mnindx; j++, i++) {
    ara[i] = ara[j];
  }
  long long id = i;
  long long tmp = m - mnval;
  ans = mnindx;
  long long p;
  if (tmp > 0) {
    if (tmp % sum == 0) {
      p = (tmp / sum);
      ans += (p * n);
    } else {
      p = (tmp / sum);
      ans += (p * n);
      tmp -= p * sum;
      for (i = mnindx + 1; i < id; i++) {
        tmp += ara[i];
        ans++;
        if (tmp <= 0) break;
      }
    }
  }
  cout << ans << endl;
}
