Matching Problem
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Please stop creating problems.
You are given two sequences and b_1, b_2, b_3, b_4.
Two sequences and match if and only if and .
Output the number of subsequences of that match b_1, b_2, b_3, b_4.

输入描述:

The first line contains one integer .
The second line contains n integers .
The third line contains four integers .

输出描述:

Output one integer - the answer.
示例1

输入

复制
10
1 5 5 4 1 4 3 3 4 4
3 3 2 1

输出

复制
20