#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long hp;
  int n;
  cin >> hp >> n;
  vector<int> d(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> d[i];
  }
  vector<long long> sum(n + 1);
  for (int i = 1; i <= n; ++i) {
    sum[i] = sum[i - 1] + d[i];
    if (sum[i] <= -hp) {
      cout << i << '\n';
      return 0;
    };
  }
  if (sum[n] >= 0) {
    cout << -1 << '\n';
    return 0;
  }
  long long mx = min_element(sum.begin() + 1, sum.end()) - sum.begin();
  long long max_damage = abs(sum[mx]);
  long long damage_round = abs(sum[n]);
  ;
  ;
  ;
  long long lo = 0;
  long long hi = hp / damage_round + 1000;
  while (hi - lo > 1) {
    long long k = (lo + hi) / 2;
    long long damage = k * damage_round + max_damage;
    if (damage >= hp) {
      hi = k;
    } else {
      lo = k;
    }
  }
  long long ans = lo * n + mx;
  hp -= lo * damage_round + max_damage;
  for (int i = 1; i <= n; ++i) {
    ans += 1;
    int index = mx + i;
    if (index > n) index -= n;
    hp += d[index];
    ;
    if (hp <= 0) {
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}
