---
{"category_name":"easy","problem_code":"COUNTA","problem_name":"A Counting Problem","problemComponents":{"constraints":"- $1 \\leq T \\leq 10$\n- $2 \\leq N \\leq 10^5$\n- $0 \\leq B_i \\leq 10^5$","constraintsState":true,"subtasks":"","subtasksState":false,"inputFormat":"- First line will contain $T$, number of testcases. Then the testcases follow.\n- The first line of each test case contains a single integer $N$\n- The second line of each test case contains $N-1$ space separated integers - the $i^{th}$ of which is $B_i$\n","inputFormatState":true,"outputFormat":"For each testcase(in a new line), output the count of valid possibilities of array $A$ modulo $10^{9} + 7$.\n","outputFormatState":true,"sampleTestCases":{"0":{"id":1,"input":"3\n2\n100\n5\n3 9 8 4\n3\n10 12","output":"199801\n199983\n199977","explanation":"**Test Case $1$:** All valid arrays $A$ are of the form $[100, x]$ and $[x, 100]$ where $100 \\leq x \\leq 10^5$. Therefore, the answer is $(10^5 - 100) + (10^5 - 100 + 1) = 199801$.\n\n**Test Case $3$:** All valid arrays $A$ are of the form $[10, 12, x]$ and $[10, x, 12]$ where $12 \\leq x \\leq 10^5$. Therefore, the answer is $(10^5 - 12) + (10^5 - 12 + 1) = 199977$. ","isDeleted":false}}},"video_editorial_url":"","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"SQLQ","53":"NEM"},"max_timelimit":1,"source_sizelimit":50000,"problem_author":"utkarsh_adm","problem_tester":"","date_added":"13-09-2021","tags":{"0":"utkarsh_adm"},"problem_difficulty_level":"Unavailable","best_tag":"","editorial_url":"","time":{"view_start_date":1631727002,"submit_start_date":1631727002,"visible_start_date":1631727002,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=COUNTA","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
Consider an array $A$ of length $N$. You know that for all $1 \leq i \leq N$, $0 \leq A_i \leq 10^5$. We construct an array $B$ of length $N-1$ such that, for all $1 \leq i \leq N - 1$, $B_i = min(A_i, A_{i + 1})$.
You are given the array $B$, you need to find out the total number of distinct arrays $A$ which we could have used to construct the given array $B$.
The answer may be large, so you need to find it modulo $10^{9} + 7$.
<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>