#include <bits/stdc++.h>
using namespace std;
const long long inf = 9e18;
long long H, n, d[200005], cs[200005], sd, minT = inf, minCS = 0;
int main() {
  cin >> H >> n;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    sd -= d[i];
    cs[i] = cs[i - 1] - d[i];
    minCS = max(cs[i], minCS);
  }
  if (sd <= 0) {
    for (int i = 1; i <= n; i++) {
      if (H - cs[i] <= 0) {
        cout << i << endl;
        return 0;
      }
    }
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    long long hl = H - cs[i];
    long long q = hl / sd;
    if (hl % sd != 0) q += 1;
    if (hl <= 0)
      minT = min(minT, (long long)i);
    else
      minT = min(minT, q * n + (long long)i);
  }
  cout << minT << endl;
  return 0;
}
