import java.io.*;
import java.util.*;

public class casino_dk_n2 {
    final int MAXN = 500000;

    long[] p = new long[MAXN + 1];

    void initsum(int n, int[] a) {
        p[0] = 0;
        for (int i = 1; i <= n; i++) {
            p[i] = p[i - 1] + a[i];
        }
    }

    long sum(int i, int j) {
        if (i > j) return 0;
        return p[j] - p[i-1];
    }



    public void solve() throws IOException {
        int t = nextInt();
        whi: while (t-- > 0) {
            int n = nextInt();
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                a[i] = nextInt();
            }
            initsum(n, a);
            double[] ans = new double[n + 1];
            RmqSparseTable sparse = new RmqSparseTable(a);
            a[0] = a[2];
            for (int i = 1; i <= n; i++) {
                if (i > 1) ans[i] = sum(2, i - 1) + sparse.max(1, i);
                for (int j = 1; j < i; j++) {
                    if (j == i - 1) {
                        ans[i] = Math.max(ans[i], ans[j - 1] + (a[j - 1] + a[j + 1] + 0.0) / 2.0);
                    } else {
                        ans[i] = Math.max(ans[i], ans[j - 1] + (a[j - 1] + a[j + 1] + 0.0) / 2.0 +  sum(j + 2, i - 1) + sparse.max(j + 1, i));
                    }

                }
               //System.err.println(ans[i]);
            }

            out.println(ans[n]);
        }
    }


    void run() throws IOException {
        //br = new BufferedReader(new InputStreamReader(System.in));
        //out = new PrintWriter(System.out);
        br = new BufferedReader(new FileReader("casino.in"));
        out = new PrintWriter("casino.out");
    
        solve();
        out.close();
    }

    BufferedReader br;
    PrintWriter out;
    StringTokenizer stok;

    String nextToken() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    char nextChar() throws IOException {
        return (char) (br.read());
    }

    String nextLine() throws IOException {
        return br.readLine();
    }

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


    public class RmqSparseTable {

        int[] logTable;
        int[][] rmq;
        int[] a;

        public RmqSparseTable(int[] a) {
            this.a = a;
            int n = a.length;

            logTable = new int[n + 1];
            for (int i = 2; i <= n; i++)
                logTable[i] = logTable[i >> 1] + 1;

            rmq = new int[logTable[n] + 1][n];

            for (int i = 0; i < n; ++i)
                rmq[0][i] = i;

            for (int k = 1; (1 << k) < n; ++k) {
                for (int i = 0; i + (1 << k) <= n; i++) {
                    int x = rmq[k - 1][i];
                    int y = rmq[k - 1][i + (1 << k - 1)];
                    rmq[k][i] = a[x] >= a[y] ? x : y;
                }
            }
        }

        public int max(int i, int j) {
            int k = logTable[j - i];
            int x = rmq[k][i];
            int y = rmq[k][j - (1 << k) + 1];
            return a[x] >= a[y] ? a[x] : a[y];
        }

    }
}
