public boolean firstWillWin(int[] values) {
        // write your code here
        int n = values.length;
        int sum = 0;
        for (int i : values)
            sum += i;
        int[][] dp = new int[n][n];
        // dp[i][j] = val[i] + min(dp[i+2][j], dp[i+1][j-1])
        //            val[j] + min(dp[i+1][j-1], dp[i][j-2]
        for (int gap = 0; gap < n; ++gap) {
            for (int i = 0, j = gap; j < n; ++i, ++j) {
                int x = (i + 2) <= j ? dp[i + 2][j] : 0;
                int y = (i + 1) <= j - 1 ? dp[i + 1][j - 1] : 0;
                int z = i <= j - 2 ? dp[i][j - 2] : 0;
                dp[i][j] = Math.max(values[i] + Math.min(x, y), values[j] + Math.min(y, z));
            }
        }
        // return dp[0][n - 1] * 2 > sum;
        return dp[0][n - 1] * 2 > sum;
    }