You are given an array **A **(distinct elements) of size** N**. Find out the maximum difference between any two elements such that larger element appears after the smaller number in **A**.

**Input:**

The first line of input contains an integer** T** denoting the number of test cases. T testcases follow. Each testcase contains two lines of input.

The first line of each test case is N,N is the size of array.

The second line of each test case contains N elements separated by spaces.

**Output:**

For each testcase, print the maximum difference between two element. Otherwise print -1

**Constraints:**

1 <= T <= 100

2 <= N <= 10^{7}

0 <= A_{i} <= 10^{7}

**Example:
Input:**

2

7

2 3 10 6 4 8 1

6

7 9 5 6 3 2

8

2

Testcase1:

lakshmi_pandey | 72 |

abbatta7 | 68 |

Ashish Kumar Vaishy | 62 |

aman19 | 58 |

Kumar Gaurav Singh | 58 |

saumitra13325 | 612 |

ashujack | 551 |

lakshmi_pandey | 544 |

aman19 | 538 |

piyushmittal25 | 514 |

blackshadows | 5249 |

akhayrutdinov | 5111 |

Ibrahim Nash | 5087 |

Quandray | 4354 |

sanjay05 | 3668 |

Login to report an issue on this page.