#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
long long h, n, a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long sum = 0, ans = 0;
  cin >> h >> n;
  long long tmp = 0, maxn = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (tmp > 0) tmp = 0;
    tmp += a[i];
    maxn = min(tmp, maxn);
  }
  tmp = h;
  ans = 0;
  for (int i = 1; i <= n; i++) {
    tmp += a[i];
    if (tmp <= 0) {
      cout << i << endl;
      return 0;
    }
  }
  if (sum >= 0) {
    cout << "-1" << endl;
    return 0;
  }
  long long tt = (h + maxn) / (-1 * sum);
  ans += tt * n;
  h = h + tt * sum;
  int i = 1;
  while (h > 0) {
    h += a[i];
    ans++;
    i++;
    if (i > n) i = 1;
  }
  cout << ans << endl;
  return 0;
}
