#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll H;
  int n;
  cin >> H >> n;
  vector<ll> a(n);
  ll sm = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sm += a[i];
  }
  ll hh = H;
  for (int i = 0; i < n; ++i) {
    hh += a[i];
    if (hh <= 0) {
      cout << i + 1;
      exit(0);
    }
  }
  if (sm >= 0) {
    cout << -1;
    exit(0);
  }
  ll cur = 0;
  ll ans = 1e18;
  ll f = abs(sm);
  ans = min(ans, ((H + f - 1) / f) * n);
  for (int i = 0; i < n; ++i) {
    cur += a[i];
    ll K = (-cur - H) / sm;
    if (H + cur + K * sm > 0) K++;
    if (H + cur + K * sm <= 0) {
      ans = min(ans, K * n + i + 1);
    }
  }
  cout << ans;
  return 0;
}
