外星人聚会 Meeting with Aliens

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=17&page=show_problem&problem=1511 [PDF](https://uva.onlinejudge.org/external/105/p10570.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10570/75eff127b98077cdef2c3b26c3fff44210406f63.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10570/c256ec0f798bf919a135d52bf42ae680f055c284.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10570/17d9fde101d8bd37e987a10349fefe1bc6d898d8.png)

输入输出样例

输入样例 #1

4
1 2 3 4
4
4 3 2 1
4
2 3 1 4
0

输出样例 #1

0
0
1