#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long H;
  int n;
  cin >> H >> n;
  vector<long long> d(n + 1, 0);
  long long peak = 0;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    d[i] = d[i - 1] + a;
    if (d[i] + H <= 0) {
      cout << i;
      return 0;
    }
    peak = min(peak, d[i]);
  }
  if (d[n] >= 0) {
    cout << -1;
  } else {
    long long ans = (H + peak + abs(d[n]) - 1) / abs(d[n]) * n;
    H -= ans / n * abs(d[n]);
    for (int i = 1; i <= n; ++i) {
      if (d[i] + H <= 0) {
        cout << ans + i;
        return 0;
      }
    }
  }
  return 0;
}
