#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int A[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  long long H;
  int n;
  long long temp = 0, temp1 = 0;
  long long ans = 0;
  cin >> H >> n;
  long long HH = H;
  long long minn = 0x3f3f3f3f3f3f3f3f;
  long long maxn = 0;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    temp += A[i];
  }
  for (int i = 1; i <= n; i++) {
    HH += A[i];
    if (HH <= 0) {
      cout << i << '\n';
      exit(0);
    }
  }
  for (int i = 1; i <= n; i++) {
    temp1 += A[i];
    minn = min(minn, temp1);
  }
  maxn = -minn;
  if (temp >= 0) {
    cout << -1 << '\n';
    exit(0);
  } else {
    long long time = (H - maxn) / -temp;
    if (time < 0) time = 0;
    ans = 1LL * time * n;
    H -= -temp * time;
    while (H > 0) {
      for (int i = 1; i <= n; i++) {
        H += A[i];
        ans++;
        if (H <= 0) break;
      }
      if (H <= 0) break;
    }
  }
  cout << ans << '\n';
  return 0;
}
