#include <bits/stdc++.h>
using namespace std;
long long h, n, sum, ma, ans, a[200005];
int main() {
  cin >> h >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    ma = min(ma, sum);
    h += a[i];
    if (h <= 0 && ans == 0) ans = i;
  }
  if (ans)
    cout << ans;
  else if (sum >= 0 && h > 0)
    cout << -1;
  else {
    ma *= -1;
    sum *= -1;
    h -= ma;
    ans = (h / sum + 1) * n;
    h %= sum;
    h += ma;
    int i = 1;
    while (h > 0) h += a[(i - 1) % n + 1], i++;
    cout << ans + i - 1;
  }
}
