import java.util.*;
class OldSchoolHero {
public static List<Integer> minOperations(int T, List<int[]> testCases) {
List<Integer> results = new ArrayList<>();
for (int t = 0; t < T; t++) {
int[] boxes = testCases.get(t);
int minValue
= Arrays.
stream(boxes
).
min().
getAsInt();
int ans=0,add=0;
for(int i=1;i<boxes.length;i++)
{
int diff = boxes[i] - boxes[i - 1] + add;
add += diff;
int temp=0;
ans+=(diff/5);
temp=diff%5;
ans+=(temp/2);
ans+=(temp%2);
// System.out.println(ans+" "+i);
}
results.add(ans);
}
return results;
}
public static void main
(String[] args
) { Scanner sc
= new Scanner
(System.
in);
int T = sc.nextInt();
List<int[]> testCases = new ArrayList<>();
for (int i = 0; i < T; i++) {
int M = sc.nextInt();
int[] boxes = new int[M];
for (int j = 0; j < M; j++) {
boxes[j] = sc.nextInt();
}
testCases.add(boxes);
}
List<Integer> results = minOperations(T, testCases);
for (int res : results) {
}
sc.close();
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgT2xkU2Nob29sSGVybyB7CiAgICBwdWJsaWMgc3RhdGljIExpc3Q8SW50ZWdlcj4gbWluT3BlcmF0aW9ucyhpbnQgVCwgTGlzdDxpbnRbXT4gdGVzdENhc2VzKSB7CiAgICAgICAgTGlzdDxJbnRlZ2VyPiByZXN1bHRzID0gbmV3IEFycmF5TGlzdDw+KCk7CiAgICAgICAgCiAgICAgICAgZm9yIChpbnQgdCA9IDA7IHQgPCBUOyB0KyspIHsKICAgICAgICAgICAgaW50W10gYm94ZXMgPSB0ZXN0Q2FzZXMuZ2V0KHQpOwogICAgICAgICAgICBpbnQgbWluVmFsdWUgPSBBcnJheXMuc3RyZWFtKGJveGVzKS5taW4oKS5nZXRBc0ludCgpOwogICAgICAgICAgICBpbnQgdG90YWxPcHMgPSBJbnRlZ2VyLk1BWF9WQUxVRTsKCiAgICAgICAgICAgQXJyYXlzLnNvcnQoYm94ZXMpOwogICAgICAgICAgICBpbnQgYW5zPTAsYWRkPTA7CiAgICAgICAgICAgIGZvcihpbnQgaT0xO2k8Ym94ZXMubGVuZ3RoO2krKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaW50IGRpZmYgPSBib3hlc1tpXSAtIGJveGVzW2kgLSAxXSArIGFkZDsKCQkJCWFkZCArPSBkaWZmOwogICAgICAgICAgICAgICAgaW50IHRlbXA9MDsKICAgICAgICAgICAgICAgIGFucys9KGRpZmYvNSk7CiAgICAgICAgICAgICAgICB0ZW1wPWRpZmYlNTsKICAgICAgICAgICAgICAgIGFucys9KHRlbXAvMik7CiAgICAgICAgICAgICAgICBhbnMrPSh0ZW1wJTIpOwogICAgICAgICAgICAgICAgLy8gU3lzdGVtLm91dC5wcmludGxuKGFucysiICIraSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgCiAgICAgICAgICAgIHJlc3VsdHMuYWRkKGFucyk7CgogICAgICAgIH0KICAgICAgICAKICAgICAgICByZXR1cm4gcmVzdWx0czsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgU2Nhbm5lciBzYyA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgCiAgICAgICAgaW50IFQgPSBzYy5uZXh0SW50KCk7CiAgICAgICAgTGlzdDxpbnRbXT4gdGVzdENhc2VzID0gbmV3IEFycmF5TGlzdDw+KCk7CiAgICAgICAgCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBUOyBpKyspIHsKICAgICAgICAgICAgaW50IE0gPSBzYy5uZXh0SW50KCk7CiAgICAgICAgICAgIGludFtdIGJveGVzID0gbmV3IGludFtNXTsKICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBNOyBqKyspIHsKICAgICAgICAgICAgICAgIGJveGVzW2pdID0gc2MubmV4dEludCgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHRlc3RDYXNlcy5hZGQoYm94ZXMpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICBMaXN0PEludGVnZXI+IHJlc3VsdHMgPSBtaW5PcGVyYXRpb25zKFQsIHRlc3RDYXNlcyk7CiAgICAgICAgZm9yIChpbnQgcmVzIDogcmVzdWx0cykgewogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4ocmVzKTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgc2MuY2xvc2UoKTsKICAgIH0KfQo=