#include <bits/stdc++.h>
using namespace std;

const int MAX = 500;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	while (cin >> n, n) {
		vector<vector<int>> dp(MAX + 1, vector<int>(n + 1, -1));
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			int p;
			cin >> p;
			for (int j = MAX; j >= 0; j--) {
				for (int k = n; k >= 0; k--) if (dp[j][k] != -1) {
					int val = (p + 999) / 1000;
					if (p % 1000 != 0 && p % 1000 <= 500) {
						dp[j + val][k + 1] = max(dp[j + val][k + 1], dp[j][k] + val * 1000 - p - 500);
					}
					else {
						dp[j + val][k] = max(dp[j + val][k], dp[j][k] + val * 1000 - p);
						if (val * 1000 - p + dp[j][k] >= 500) {
							dp[j + val][k + 1] = max(dp[j + val][k + 1], dp[j][k] + val * 1000 - p - 500);
						}
					}
				}
			}
		}
		int cnt = 0, sum = 0;
		for (int i = 0; i <= MAX; i++) {
			for (int j = 0; j <= n; j++) if (dp[i][j] != -1) {
				if (j > cnt) {
					cnt = j;
					sum = i * 1000 - j * 500 - dp[i][j];
				}
				else if (j == cnt) {
					sum = min(sum, i * 1000 - j * 500 - dp[i][j]);
				}
			}
		}
		cout << cnt << ' ' << sum << endl;
	}
	return 0;
}

