// Author: Adrian Kuegel
// Algorithm: Dynamic Programming
// Complexity: O(n^3)
// Date: June 10'th, 2009
// Reconstructs the solution

#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <assert.h>
#include <algorithm>
using namespace std;

#define MAXN 128

int c[MAXN];
int dp[MAXN+1][MAXN+1];
int prev[MAXN+1][MAXN+1];

int main() {
	int n;
//	freopen("elias.in", "r", stdin);
	while(scanf("%d", &n) == 1 && n) {
		assert(n > 0 && n <= MAXN);
		for (int i=0; i<n; ++i) {
			scanf("%d", &c[i]);
			assert(c[i] >= 0 && c[i] <= 100000);
		}
		for (int i=0; i<n; ++i) {
			int sum = 0;
			for (int j=0; j<=i+1; ++j)
				dp[i+1][j] = INT_MAX;
			for (int j=i; j>=0; --j) {
				sum += c[j];
				for (int k=(j?1:0); k<=j; ++k) {
					int other = dp[j][k] + sum * (k + i + 2);
					if (other < dp[i+1][k+1]) {
						dp[i+1][k+1] = other;
						prev[i+1][k+1] = j;
					}
				}
			}
		}
		int k, opt = INT_MAX;
		for (int i=1; i<=n; ++i)
			if (opt > dp[n][i]) {
				opt = dp[n][i];
				k = i;
			}
		printf("%d\n", opt);
		int cur = n;
		do {
			printf("%0*d indicates %d bits following\n", k, 1, cur);
			cur = prev[cur][k];
		}while(--k);
		puts("");
	}
	return 0;
}
