#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define vn vector<ll>
using namespace std;
const int MAX_N = 1e9 + 7;
#define pii pair<ll,ll>
const ll INF = 0x3f3f3f3f3f3f3f3f;
#define pb push_back
#define srt(vp) sort(vp.begin(), vp.end())
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h, n;
  cin >> h >> n;
  vn v(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
  }
  
  if (sum <= 0) {
    cout << "-1 -1" << endl;
  } else {
    ll rem = h % sum;
    if (rem == 0) cout << (h / sum) << " " << (n - 1) << endl;
    else {
      ll curr = 0;
      ll i = 0;
      while (curr < rem && i < n) {
        curr += v[i++];
      }
      if (curr >= rem) cout << (h / sum) << " " << (i - 1) << endl;
      else cout << -1 << endl; 
    }
  }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |