func_code_string: #include <bits/stdc++.h>   using namespace std;   char buf[10000001], *ptr = buf - 1;   inline int read() {     int x = 0, c = *++ptr;     while (c < 48) c = *++ptr;     while (c > 47) x = x * 10 + c -  0 , c = *++ptr;     return x;   }   const int MAXN = 500005;   const int MOD = 1000000007;   int s[MAXN], a[MAXN], b[MAXN];   int c[MAXN], cnt[MAXN];   int n;   inline int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; }   inline void modify(int i, int t) {     while (i <= n) s[i] = add(s[i], t), i += i & -i;   }   inline int query(int i) {     int res = 0;     while (i) res = add(res, s[i]), i -= i & -i;     return res;   }   int main(int argc, char const *argv[]) {     fread(buf, 1, sizeof(buf), stdin)[buf] = 0;     int x, ans = 0;     n = read();     for (int i = 1; i <= n; ++i) b[i] = c[i] = a[i] = read();     sort(b + 1, b + 1 + n);     for (int i = 1; i <= n; ++i) {       x = lower_bound(b + 1, b + 1 + n, a[i]) - b;       modify(x, i);       cnt[i] = (cnt[i] + (long long)query(x - 1) * (n - i + 1)) % MOD;     }     memset(s, 0, sizeof(s));     reverse(a + 1, a + 1 + n);     for (int i = 1; i <= n; ++i) {       x = lower_bound(b + 1, b + 1 + n, a[i]) - b;       modify(x, i);       cnt[n - i + 1] =           (cnt[n - i + 1] + (long long)query(x - 1) * (n - i + 1)) % MOD;     }     for (int i = 1; i <= n; ++i)       ans = (ans + (cnt[i] + (long long)i * (n - i + 1)) % MOD * c[i]) % MOD;     printf( %d , ans);     return 0;   }   