#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
const int inf = 1e9 + 1e8;
const long long INF = 1e18 + 1e17;
const int MOD1 = 998244353;
const int MOD2 = 1e9 + 7;
int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
bool is_prime(int x) {
  if (x == 1 || (!(x % 2) && x > 2)) return false;
  for (int i = 3; i * i <= x; i += 2) {
    if (!(x % i)) {
      return false;
    }
  }
  return true;
}
bool is_palindrome(string str) {
  for (int i = 0; i < str.length() / 2; i++) {
    if (str[i] != str[str.length() - 1 - i]) {
      return false;
    }
  }
  return true;
}
long long NCR(int n, int r) {
  if (n < r || r < 0 || n <= 0) return 0;
  if (r > n / 2) return NCR(n, n - r);
  long long res = 1;
  for (long long k = 1; k <= r; k++) {
    res *= n - k + 1;
    res /= k;
  }
  return res;
}
long long H, arr[MAXN];
long long pre[MAXN], total, ans;
long long N;
int main() {
  cin >> H >> N;
  long long minn = inf;
  long long cur = H;
  for (int i = 1; i <= N; i++) {
    cin >> arr[i];
    pre[i] = (i == 1 ? arr[i] : pre[i - 1] + arr[i]);
    if (pre[i] + cur <= 0 && !ans) {
      ans = i;
    }
    minn = min(minn, pre[i]);
  }
  total = pre[N];
  if (!ans && pre[N] >= 0) {
    cout << "-1" << endl;
    return 0;
  } else if (ans) {
    cout << ans << endl;
    return 0;
  }
  long long cycles = (cur + minn - 1) / (-total) + 1;
  cur += cycles * total;
  for (int i = 1; i <= N; i++) {
    if (pre[i] + cur <= 0) {
      ans = cycles * N + i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
