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

public class casino_dk {
    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];
    }

    class Pair {
        int i;
        double sum, max, prefsum, push;

        Pair(int i, double sum, int max) {
            this.i = i;
            this.sum = sum;
            this.max = max;
        }
    }

    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];
            Stack<Pair> stack = new Stack<Pair>();

            ans[2] = Math.max(a[1], a[2]);
            stack.push(new Pair(0, 0, Math.max(a[1], a[2])));
            stack.peek().prefsum = Math.max(a[1], a[2]);

            for (int i = 3; i <= n; i++) {
                double maxsum = 0;
                int j = -1;
                double add = 0;
                stack.peek().push += a[i - 1];

                Pair pair = (i == 2) ? (new Pair(2, a[2], a[2])) : ( new Pair(i - 1, (a[i - 1] + a[i - 3] + .0) / 2 + ans[i - 3], a[i - 1]));

                pair.prefsum = pair.sum + pair.max;
                if (!stack.isEmpty()) {
                    pair.prefsum = Math.max(pair.prefsum, stack.peek().prefsum + stack.peek().push);
                }
                stack.push(pair);

                boolean hasKeyElem = false;
                while (!stack.isEmpty() && stack.peek().max <= a[i]) {
                    Pair pair1 = stack.pop();
                    add += pair1.push;
                    if (maxsum < pair1.sum + add) {
                        j = pair1.i;
                        hasKeyElem = true;
                        maxsum = pair1.sum + add;
                    }
                }
                if (!hasKeyElem) {
                    ans[i] = Math.max(stack.peek().prefsum + stack.peek().push, ans[i - 2] + (a[i] + a[i - 2] + .0) / 2);
                    continue;
                }

                if (hasKeyElem) {
                    Pair pair1 = new Pair(j, maxsum, a[i]);
                    pair1.prefsum = pair1.sum + pair1.max;
                    if (!stack.isEmpty()) {
                        stack.peek().push += add;
                        pair1.prefsum = Math.max(stack.peek().prefsum + stack.peek().push, pair1.prefsum);
                    }
                    stack.push(pair1);
                    ans[i] = Math.max(pair1.prefsum,  ans[i - 2] + (a[i] + a[i - 2] + .0) / 2);
                }
            }
            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().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];
        }

    }
}
