#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 50;
long long H, n, a[maxn], tmp[maxn];
int main() {
  cin >> H >> n;
  long long minx = 0x3f3f3f;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    tmp[i] = a[i] + tmp[i - 1];
    minx = min(minx, tmp[i]);
  }
  if (H + minx <= 0) {
    for (int i = 1; i <= n; i++) {
      if (H + tmp[i] <= 0) {
        cout << i << endl;
        return 0;
      }
    }
  } else if (tmp[n] >= 0) {
    cout << -1 << endl;
  } else {
    long long temp = H + minx;
    long long mo = temp % (-tmp[n]);
    long long to, t;
    if (mo != 0) {
      to = (-tmp[n]) - mo;
      t = (to + temp) / (-tmp[n]);
    } else {
      to = 0;
      t = (temp) / (-tmp[n]);
    }
    temp = (-minx) - to;
    long long ans = t * n;
    for (int i = 1; i <= n; i++) {
      if (temp + tmp[i] <= 0) {
        ans += i;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
