public ListNode rotateRight(ListNode head, int n) {
        if (head == null || head.next == null) {
            return head;
        }
        int length = 0;
        ListNode it = head;
        while (it != null) {
            length++;
            it = it.next;
        }
        
        
        ListNode dummy = new ListNode(0);
        dummy.next = head;
        it = dummy;
        for (int i = 0; i < length - (n % length); i++) {
            it = it.next;
        }
        
        ListNode insert_point = dummy;
        while (it.next != null) {
            ListNode move_node = it.next;
            it.next = move_node.next;
            move_node.next = insert_point.next;
            insert_point.next = move_node;
            insert_point = move_node;
        }
        return dummy.next;
    }