#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
long long maxl(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long minl(long long a, long long b) {
  if (a > b) return b;
  return a;
}
long long mod = 998244353;
long long mulmod(long long a, long long b, long long c) {
  long long res = 0;
  a = a % c;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res + a) % c;
    }
    a = (a * 2) % c;
    b /= 2;
  }
  return res % c;
}
int binarySearch(int arr[], int l, int r, int x) {
  if (r >= l) {
    int mid = l + (r - l) / 2;
    if (arr[mid] == x) return mid;
    if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
    return binarySearch(arr, mid + 1, r, x);
  }
  return -1;
}
int a[100005];
int tree[200005];
void build(int st, int low, int high) {
  if (low == high) {
    tree[st] = a[high] % 2;
    return;
  }
  int mid = low + (high - low) / 2;
  build(2 * st, low, mid);
  build(2 * st + 1, mid + 1, high);
  tree[st] = tree[2 * st] + tree[2 * st + 1];
}
void update(int st, int start, int end, int ind, int val) {
  if (start == end) {
    tree[st] = val % 2;
    return;
  }
  int mid = start + (end - start) / 2;
  if (ind <= mid) {
    update(2 * st, start, mid, ind, val);
  } else
    update(2 * st + 1, mid + 1, end, ind, val);
  tree[st] = tree[2 * st] + tree[2 * st + 1];
}
int query(int st, int start, int end, int low, int high) {
  if (start > high || end < low) return 0;
  int mid = start + (end - start) / 2;
  if (start == low && end == high) {
    return tree[st];
  }
  if (low > mid) return query(2 * st + 1, mid + 1, end, low, high);
  if (high <= mid) return query(2 * st, start, mid, low, high);
  return query(2 * st, start, mid, low, mid) +
         query(2 * st + 1, mid + 1, end, mid + 1, high);
}
int main() {
  ios_base::sync_with_stdio(false);
  long long h, n;
  cin >> h >> n;
  long long d[n];
  for (int i = 0; i < n; i++) cin >> d[i];
  long long pref[n];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += d[i];
    pref[i] = sum;
    if (h + pref[i] <= 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  if (sum >= 0) {
    cout << "-1" << endl;
    return 0;
  }
  long long mini = ceil(double(h) / abs(sum)) * n;
  for (int i = 0; i < n; i++) {
    if (pref[i] < 0) {
      long long a = abs(pref[i]);
      mini = minl(mini, ceil((double(h - a)) / abs(sum)) * n + i + 1);
    }
  }
  cout << mini << endl;
  return 0;
}
