#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long minu = 0, hp, n, s = 0;
  long long mn = LONG_LONG_MAX;
  cin >> hp >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    s += arr[i];
    mn = min(mn, s);
  }
  if (abs(mn) >= hp) {
    minu = 0;
    for (int i = 0; i < n; i++) {
      minu++;
      hp += arr[i];
      if (hp <= 0) {
        cout << minu;
        return 0;
      }
    }
  }
  if (s > 0) {
    cout << "-1";
    return 0;
  }
  if (s == 0 && hp != 0) {
    cout << "-1";
    return 0;
  }
  long long rem = hp - abs(mn);
  long long num = (rem / abs(s));
  if (rem % (abs(s)) == 0) num--;
  hp += num * s;
  minu = num * n;
  if (hp == 0) {
    cout << minu;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    minu++;
    hp += arr[i];
    if (hp <= 0) {
      cout << minu;
      return 0;
    }
  }
  if (hp == 0) {
    cout << minu;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    minu++;
    hp += arr[i];
    if (hp <= 0) {
      cout << minu;
      return 0;
    }
  }
}
