## Delete the Middle of the Linked List

Given a singly linked list, delete middle node of the linked list. If there are even nodes, then there would be two middle nodes, we need to delete the second middle element.
After deleting the node, print the linked list.
In case of a single node, print the head of a linked list containing only 1 node which has value -1.

#### Input

The first line contains an integer n, the length of the linked list.
The next line contains n integers, the elements of the linked list.

#### Constraints:

1 <= n <= 1000
1 <= list[i] <= 1000, where list[i] is the ith element of the list.

#### Output

Print the linked list after deleting the middle node in new line.

### Example

```5
1 2 3 4 5
```

#### Output:

```1 2 4 5
```

#### Explanation:

```After deleting middle of the linked list, 3 will be deleted and the list will be as 1, 2, 4, 5.
```

```6
1 2 3 4 5 6
```

#### Output:

```1 2 3 5 6
```

#### Explanation:

```After deleting middle of the linked list, 4 will be deleted and the list will be as 1, 2, 3, 5, 6.
```

## Solution of Delete the Middle of the Linked List:–

```import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{

class Node{
int data;
Node next;

Node(int x)
{
data=x;
next=null;
}
}

{
Node newNode = new Node(x);
{
return;
}

while(temp.next!=null)
{
temp=temp.next;
}
temp.next=newNode;
return;
}

void deleteMiddle(int n)
{
if(n==0)
{
return;
}

{
return;
}

{
return;
}

int i=0;
Node demo=null;
while(i<(n/2) && temp.next!=null)
{
demo=temp;
temp=temp.next;
i++;
}
demo.next=temp.next;
return;
}

void printList()
{

{
System.out.println(-1);
return;
}

while(temp!=null)
{
System.out.print(temp.data+" ");
temp=temp.next;
}
}

public static void main (String[] args) throws java.lang.Exception
{
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}