#P1102E. Monotonic Renumeration
Monotonic Renumeration
Description
You are given an array consisting of integers. Let's denote monotonic renumeration of array as an array consisting of integers such that all of the following conditions are met:
- ;
- for every pair of indices and such that , if , then (note that if , it is still possible that );
- for every index either or .
For example, if , then two possible monotonic renumerations of are and .
Your task is to calculate the number of different monotonic renumerations of . The answer may be large, so print it modulo .
The first line contains one integer () — the number of elements in .
The second line contains integers ().
Print one integer — the number of different monotonic renumerations of , taken modulo .
Input
The first line contains one integer () — the number of elements in .
The second line contains integers ().
Output
Print one integer — the number of different monotonic renumerations of , taken modulo .