#include <bits/stdc++.h>
using namespace std;
long long m, n;
long long a[200010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> m >> n;
  long long res = 1e18;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) cin >> a[i], sum += a[i];
  long long nw = 0;
  for (int i = 0; i < n; ++i) {
    nw += a[i];
    if (nw + m <= 0) {
      cout << i;
      return 0;
    }
  }
  if (sum >= 0) {
    cout << -1;
    return 0;
  }
  sum = -sum;
  nw = 0;
  for (int i = 0; i < n; ++i) {
    nw += a[i];
    long long x = nw + m;
    long long t = 0;
    if (x % sum == 0)
      t = x / sum;
    else
      t = x / sum + 1;
    res = min(res, t * n + i);
  }
  cout << res;
}
