#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  for (auto i : v) {
    out << i << ' ';
  }
  return out;
}
template <class T>
istream &operator>>(istream &in, vector<T> &v) {
  for (auto &i : v) {
    in >> i;
  }
  return in;
}
int main() {
  long long H, n;
  cin >> H >> n;
  vector<long long> d(n);
  cin >> d;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += d[i];
    if (abs(sum) >= H && sum < 0) {
      cout << i + 1;
      return 0;
    }
  }
  if (sum >= 0) {
    cout << -1;
    return 0;
  }
  vector<long long> prefsums(n + 1);
  for (int i = 0; i < d.size(); i++) {
    prefsums[i + 1] = prefsums[i] + d[i];
  }
  long long minans = 1e18;
  sum = abs(sum);
  for (int i = 0; i < prefsums.size(); i++) {
    long long now = (H + prefsums[i]);
    long long nowans = i + (now + sum - 1) / sum * n;
    minans = min(minans, nowans);
  }
  cout << minans;
}
