public static ListNode rotateRight(ListNode head, int n) {
        if(n == 0 || head == null || head.next == null) return head;

        ListNode node = head, first = head, second = head;
        int len = 0;
        while(node != null){
            node = node.next;
            len++;
        }

        n = n % len;
        if(n == 0) return head;

        for(int i = 0; i < n; i++) second = second.next;

        while(second.next != null){
            first = first.next;
            second = second.next;
        }

        ListNode result = first.next;
        first.next = null;
        second.next = head;
        return result;
    }