#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pairll pair<ll,ll>
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7, base = 256;
ll h, n;
ll x[N];
void solve() {
	cin >> h >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> x[i];
	}
	ll up = 0;
	for (int i = 1; i <= n; i ++) {
		up += x[i];
	}
	if (up < 0) {
		cout << -1 << " " << -1;
	}
	ll day = 0, hour = 0;
	while (h >= up) {
		day ++;
		h -= up;
	}
	cout << max (day - 1, 0LL) << " ";
	for (int i = 1; i <= n; i ++) {
		if (h >= 0) {
			h -= x[i];
			hour ++;
		}
		else break;
	}
	cout << (hour - 1 + n) % n;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll testcase = 1;
//	cin >> testcase;
	while (testcase --)
		solve();
}
//road to national prize
| # | 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... |