func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   const int MOD = 1e9 + 7;   int aa[N];   int tree[4 * N];   int query(int v, int l, int r, int L, int R) {     if (l > r || l > R || r < L) return 0;     if (L <= l && r <= R) return tree[v];     int v1 = 2 * v + 1;     int v2 = 2 * v + 2;     int mid = (l + r) / 2;     int q1 = query(v1, l, mid, L, R);     int q2 = query(v2, mid + 1, r, L, R);     return (q1 + q2) % MOD;   }   void update(int v, int l, int r, int pos, int newVal) {     if (l > r || l > pos || r < pos) return;     if (l == r && l == pos) {       tree[v] = newVal;       return;     }     int v1 = 2 * v + 1;     int v2 = 2 * v + 2;     int mid = (l + r) / 2;     update(v1, l, mid, pos, newVal);     update(v2, mid + 1, r, pos, newVal);     tree[v] = (tree[v1] + tree[v2]) % MOD;   }   int bpow(long long bb, int ee) {     if (ee < 0) return 0;     int res = 1;     while (ee > 0) {       if (ee % 2 == 1) res = res * bb % MOD;       bb = bb * bb % MOD;       ee >= 1;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> aa[i];     const int ml = 1e6;     update(0, 0, ml, 0, 1);     long long ans = 0;     for (int i = 1; i <= n; i++) {       int s = query(0, 0, ml, 0, aa[i]);       int hm = (s * 1LL * aa[i]) % MOD;       update(0, 0, ml, aa[i], hm);     }     set<int> dict;     for (int i = 1; i <= n; i++) dict.insert(aa[i]);     for (int i : dict) ans += query(0, 0, ml, i, i);     cout << ans % MOD <<   n ;     return 0;   }   