#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX = 500000;

int a[MAX + 2];
double d[MAX + 2][2];

double dynamic(int i, bool fed) {
    if (d[i][fed] != -1)
        return d[i][fed];
    if (fed)
        d[i][fed] = max(a[i + 1] + dynamic(i + 1, true), dynamic(i + 1, false));
    else
        d[i][fed] = max((a[i - 1] + a[i + 1]) / 2.0 + dynamic(i + 1, true), a[i - 1] + dynamic(i + 1, false));
    return d[i][fed];
}

int main() {
    freopen("casino.in", "r", stdin);
    freopen("casino.out", "w", stdout);
    int tn;
    scanf("%d", &tn);
    for (int test = 0; test < tn; test++) {
        int n;
        scanf("%d", &n);
        for (int i = 1; i <= n; i++) {
            scanf("%d", &a[i]);
        }
        for (int i = 0; i < n + 2; i++) {
            for (int j = 0; j < 2; j++) {
                d[i][j] = -1;
            }
        }
        d[n][0] = a[n - 1];
        d[n][1] = 0;
        printf("%lf\n", dynamic(1, true));
    }
    return 0;
}
