#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1000;
const long long INF64 = 1e18 + 1000;
const int N = 6 * 100 * 1000 + 100;
const int MOD = 1e9 + 7;
int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long h, s, s_add;
  int n;
  cin >> h >> n;
  vector<int> a(n);
  s = 0;
  s_add = 0;
  for (int i = 0; i < int(n); ++i) {
    cin >> a[i];
    s += 1ll * a[i];
    if (s + h <= 0) {
      cout << i + 1;
      return 0;
    }
    if (a[i] >= 0) s_add += a[i];
  }
  if (s >= 0) {
    cout << -1;
    return 0;
  }
  long long h_mem = h;
  long long num = h / (-s);
  long long t = num * a.size();
  h -= num * (-s);
  while (h <= s_add) {
    h -= s;
    t -= a.size();
  }
  int i = 0;
  while (h > 0) {
    h += a[i % n];
    i++;
  }
  cout << t + i;
}
