Codeforces Round 187 (Div. 1)
C
Sereja and Subsequences
Codeforces
2000
原题
← BD →
翻译中…

Sereja has a sequence that consists of $*n*$ positive integers, $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$.

翻译中…

First Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence $*a*$. Then for each sequence written on the squared paper, Sereja wrote on a piece of lines paper all sequences that do not exceed it.

翻译中…

A sequence of positive integers $*x* = *x*_{1}, *x*_{2}, ..., *x*_{*r*}$ doesn't exceed a sequence of positive integers $*y* = *y*_{1}, *y*_{2}, ..., *y*_{*r*}$, if the following inequation holds: $*x*_{1} ≤ *y*_{1}, *x*_{2} ≤ *y*_{2}, ..., *x*_{*r*} ≤ *y*_{*r*}$.

翻译中…

Now Sereja wonders, how many sequences are written on the lines piece of paper. Help Sereja, find the required quantity modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

Input

翻译中…

The first line contains integer $*n*$ $(1 ≤ *n* ≤ 10^{5})$. The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ $(1 ≤ *a*_{*i*} ≤ 10^{6})$.

翻译中…

Output

翻译中…

In the single line print the answer to the problem modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

样例

Input #1
1
42
Output #1
42
InputCopy OutputCopy
Input #2
3
1 2 2
Output #2
13
InputCopy OutputCopy
Input #3
5
1 2 3 4 5
Output #3
719
InputCopy OutputCopy
题目信息
题号
314C
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。