#include #include #include #include #include using namespace std; int main() { long long a[4000], b[800000], n, count = 0, p, ans = 0, max; cin>>n; for(int i = 0; i>a[i]; for(int i = 0; imax) max = a[k]; b[count++] = max; } for(int i = 0; imax) max = b[k]; ans = (ans + max)%1000000007; } cout<