var isBoxIn3X3 = function(arr) {
var oArr = quickSort(arr);
var aSum = sum(oArr);
var cSum = 0;
var maxDelta = oArr[oArr.length - 1] - oArr[0];
var row = parseInt(maxDelta / 3) + 1;
var col = maxDelta - row * 3 + 3 + 1;
return (row * col === oArr.length && aSum === (oArr[oArr.length - 1]+oArr[0]) / 2 * col * row)
}
var sum = function(arr) {
var total = 0;
for (var i = 0; i < arr.length; i++) {
total += arr[i];
}
return total;
}
var quickSort = function(arr) {
if (arr.length <= 1) { return arr; }
var pivotIndex = Math.floor(arr.length / 2);
var pivot = arr.splice(pivotIndex, 1)[0];
var left = [];
var right = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i] <= pivot) {
left.push(arr[i]);
}
else {
right.push(arr[i]);
}
}
return quickSort(left).concat([pivot], quickSort(right));
}