func_code_string: #include <bits/stdc++.h>   using namespace std;   long long c[100005], a[100005], b[100005], cur[100005];   int n, m;   void update(int x, long long y) {     while (x <= m) {       c[x] += y;       if (c[x] >= 1000000007) c[x] -= 1000000007;       x += x & (-x);     }   }   long long query(int x) {     long long sum = 0;     while (x > 0) {       sum += c[x];       if (sum >= 1000000007) sum -= 1000000007;       x -= x & (-x);     }     return sum % 1000000007;   }   int main() {     int i, j;     while (~scanf( %d , &n)) {       for (i = 0; i < n; i++) scanf( %I64d , &a[i]), b[i] = a[i];       sort(b, b + n);       m = unique(b, b + n) - b;       memset(c, 0, sizeof(c));       memset(cur, 0, sizeof(cur));       for (i = 0; i < n; i++) {         j = lower_bound(b, b + m, a[i]) - b + 1;         long long t = query(j), t1 = cur[j];         cur[j] = (t * a[i] + a[i]) % 1000000007;         t = cur[j] - t1;         if (t < 0) t += 1000000007;         update(j, t);       }       long long sum = 0;       for (i = 1; i <= m; i++) sum += cur[i];       sum %= 1000000007;       if (sum < 0) sum += 1000000007;       printf( %I64d n , sum);     }     return 0;   }   