// Arup Guha
// 3/7/2016
// Solution to 2015 MCPC Problem E: Kitchen Measurements

import java.util.*;
import java.io.*;

public class kitchen {

	public static int n;
	public static int[] cups;
	public static int target;

	public static void main(String[] args) throws Exception {

		// Read in all input.
		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();
		cups = new int[n];
		for (int i=0; i<n; i++)
			cups[i] = stdin.nextInt();
		target = stdin.nextInt();

		// Run our adjusted breadth first search.
		int res = bfs();

		// Output result.
		if (res == -1)
			System.out.println("impossible");
		else
			System.out.println(res);
	}

	public static int bfs() {

		HashMap<Long,Integer> map = new HashMap<Long,Integer>();
		map.put( ((long)cups[0]) << (7*n-7), 0);

		PriorityQueue<item> q = new PriorityQueue<item>();
		q.offer(new item(((long)cups[0]) << (7*n-7), 0));

		// Set up a modified BFS.
		while (q.size() > 0) {

			// Get next item.
			item code = q.poll();
			int[] cur = expand(code.mask);

			// We got a solution!
			if (cur[0] == target) return code.cost;

			// Get all of the possible next items.
			ArrayList<item> next = getNext(code);

			// Try enqueing each one - only if it hasn't been seen before, or this cost is better.
			for (item x: next) {
				if (!map.containsKey(x.mask) || x.cost < map.get(x.mask)) {
					q.offer(x);
					map.put(x.mask, x.cost);
				}
			}
		}

		// Means we never did it.
		return -1;
	}

	// Condenses arr into a single integer by group each item in a group of 7 bits.
	public static long getState(int[] arr) {
		long res = 0;
		for (int i=0; i<arr.length; i++)
			res = (res << 7) + arr[i];
		return res;
	}

	// Expands mask back into int array of size n.
	public static int[] expand(long mask) {
		int[] res = new int[n];
		for (int i=0; i<n; i++) {
			res[n-1-i] = (int)(mask & (127L));
			mask = mask >> 7;
		}
		return res;
	}

	public static ArrayList<item> getNext(item code) {

		ArrayList<item> res = new ArrayList<item>();

		int dist = code.cost;
		int[] cur = expand(code.mask);

		// Try pouring between each pair of cups.
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				if (i == j) continue;

				int[] tmp = Arrays.copyOf(cur, n);
				int pour = Math.min(tmp[i], cups[j]-tmp[j]);
				tmp[i] -= pour;
				tmp[j] += pour;

				// This is a reachable state from cur.
				res.add(new item(getState(tmp), dist+pour));
			}
		}

		// Here are all of the possible next steps.
		return res;
	}

	public static void print(int[] a) {
		for (int i=0; i<a.length; i++)
			System.out.print(a[i]+" ");
		System.out.println();
	}

}

class item implements Comparable<item> {

	public long mask;
	public int cost;

	public item(long m, int c) {
		mask = m;
		cost = c;
	}

	public int compareTo(item other) {
		return this.cost - other.cost;
	}
}