#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 100010;
const int MOD = 1000000007;
struct node {
  long long num;
  int id;
};
node a[MAXN];
bool cmp(node x, node y) {
  return x.num != y.num ? x.num < y.num : x.id < y.id;
}
long long bit[MAXN] = {0};
int n;
long long sum(int i) {
  long long s = 0;
  while (i > 0) {
    s += bit[i];
    if (s >= MOD) s -= MOD;
    i -= (i & (-i));
  }
  return s;
}
void add(int i, long long x) {
  while (i <= n) {
    bit[i] += x;
    if (bit[i] >= MOD) bit[i] -= MOD;
    i += (i & (-i));
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i].num);
    a[i].id = i;
  }
  sort(a + 1, a + n + 1, cmp);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long temp;
    if (a[i].num != a[i - 1].num)
      temp = (sum(a[i].id - 1) + 1) * a[i].num % MOD;
    else
      temp =
          (sum(a[i].id - 1) - sum(a[i - 1].id - 1) + 2 * MOD) * a[i].num % MOD;
    add(a[i].id, temp);
    ans += temp;
    if (ans >= MOD) ans -= MOD;
  }
  printf("%lld\n", ans);
  return 0;
}
