public long permutationIndex(int[] A) {
        // Write your code here
        origin = new int[A.length];
        for (int i = 0; i < A.length; ++i) {
            origin[i] = A[i];
        }
        Arrays.sort(A);
        ArrayList<Integer> path = new ArrayList<Integer>();
        HashSet<Integer> visited = new HashSet<Integer>();
        dfs(A, path, visited);
        return count;
    }