#include <bits/stdc++.h>
#pragma GCC optimize("03")
using namespace std;
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cerr << b << " = " << a << " ";
    call(++it, ed, rest...);
  }
};
vector<long long int> hr;
int main() {
  long long int h, n;
  cin >> h >> n;
  long long int k = 0;
  for (unsigned int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    k += x;
    hr.push_back(x);
  }
  long long int u = 0;
  long long int minimal = 0;
  for (unsigned int i = 0; i < n; i++) {
    u += hr[i];
    if (-u >= h) {
      cout << (i + 1) << endl;
      return 0;
    }
    if (i < n) minimal = min(minimal, u);
  }
  u = k;
  if (u >= 0) {
    cout << "-1" << endl;
    return 0;
  }
  long long int c = n;
  long long int d = (h + minimal) / abs(u);
  d = abs(d);
  d = max(0LL, d - 1);
  c = abs(d * n);
  long long int f = (u * d);
  long long int m = abs(c * u);
  for (unsigned int i = 0; i < 3 * n; i++) {
    if (-f >= h) {
      cout << c << endl;
      return 0;
    }
    long long int j = i % n;
    f += hr[j];
    ++c;
  }
}
