import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class coins_as_int {
    final int n = 12;
    final int m = 17;
    
    int[][] ends = {
            {0, 1}, {1, 2}, {2, 3},
            {0, 4}, {1, 5}, {2, 6}, {3, 7},
            {4, 5}, {5, 6}, {6, 7},
            {4, 8}, {5, 9}, {6, 10}, {7, 11},
            {8, 9}, {9, 10}, {10, 11}
    };

    int[][] edges = {
            {0, 3}, {0, 1, 4}, {1, 2, 5}, {2, 6},
            {3, 7, 10}, {4, 7, 8, 11}, {5, 8, 9, 12}, {6, 9, 13},
            {10, 14}, {11, 14, 15}, {12, 15, 16}, {13, 16}
    };

    int[] collect;
    boolean[] path;
    boolean[] vis;

    int dfsPath(int u) {
        vis[u] = true;
        int r = 0;
        for (int j = 0; j < edges[u].length; j++) {
            int e = edges[u][j];
            if (collect[e] == 0) {
                continue;
            }
            if (path[e]) {
                r++;
            }
            int v = ends[e][1];
            if (u == v) {
                v = ends[e][0];
            }
            if (!vis[v]) {
                r += dfsPath(v);
            }
        }
        return r;
    }

    int dfs(int u) {
        vis[u] = true;
        int r = 0;
        for (int j = 0; j < edges[u].length; j++) {
            int e = edges[u][j];
            if (collect[e] == 0) {
                continue;
            }
            int v = ends[e][1];
            r += collect[e];
            if (u == v) {
                v = ends[e][0];
            }
            if (!vis[v]) {
                r += dfs(v);
            }
        }
        return r;
    }

    public void run() throws IOException {
        in = new FastScanner(new FileInputStream("coins.in"));
        out = new PrintWriter("coins.out");

        int[] a = new int[m];
        int[] cnt = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = in.nextInt();
            int x = a[i];
            while (x > 0) {
                cnt[i]++;
                x /= 2;
            }
        }

        collect = new int[m];
        path = new boolean[m];
        vis = new boolean[n];
        int[] deg = new int[n];

        int ans = 0;
        for (int mask = 0; mask < (1 << m); mask++) {
            boolean good = true;

            for (int i = 0; i < m; i++) {
                int v = (mask >> i) & 1;
                path[i] = v == 1;
                if (cnt[i] % 2 == v) {
                    collect[i] = a[i];
                } else {
                    if (a[i] == 0) {
                        good = false;
                        break;
                    }
                    collect[i] = a[i] - 1;
                }
            }
            if (!good) {
                continue;
            }

            Arrays.fill(deg, 0);
            for (int i = 0; i < m; i++) {
                if ((mask & (1 << i)) != 0) {
                    deg[ends[i][0]]++;
                    deg[ends[i][1]]++;
                }
            }
            int oddCnt = 0;
            for (int i = 0; i < n; i++) {
                if (deg[i] % 2 != 0) {
                    oddCnt++;
                }
            }
            if (oddCnt > 2) {
                continue;
            }

            Arrays.fill(vis, false);
            int cntNonZero = 0;
            for (int i = 0; i < n; i++) {
                if (!vis[i]) {
                    int size = dfsPath(i);
                    if (size > 0) {
                        cntNonZero++;
                    }
                }
            }
            if (cntNonZero > 1) {
                continue;
            }

            Arrays.fill(vis, false);
            for (int i = 0; i < n; i++) {
                if (!vis[i]) {
                    int v = dfs(i) / 2;
                    if (v > ans) {
                        ans = v;
                    }
                }
            }
        }

        out.println(ans);
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        new coins_as_int().run();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}