CF314C Sereja and Subsequences

Description

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}

Input Format

The first line contains integer $ n $ $ (1

Output Format

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