#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;
const long long MAXN = (1LL << 63) - 1;
const long long MAX = (1 << 31) - 1;
long long c[100100];
long long b[100100];
int n, rk;
struct node {
  int x, _rank, pos;
} a[110000];
bool cmpx(node i, node j) { return i.x < j.x; }
bool cmppos(node i, node j) { return i.pos < j.pos; }
int lowbit(int x) { return x & (-x); }
long long sum(int x) {
  long long ret = 0;
  while (x > 0) {
    ret = (ret + c[x]) % MOD;
    x -= lowbit(x);
  }
  return ret;
}
void add(int x, long long d) {
  while (x <= rk) {
    c[x] = (c[x] + d) % MOD;
    x += lowbit(x);
  }
}
int main() {
  while (~scanf("%d", &n)) {
    memset(c, 0, sizeof(c));
    memset(b, 0, sizeof(b));
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i].x);
      a[i].pos = i;
    }
    sort(a, a + n, cmpx);
    rk = 1;
    a[0]._rank = 1;
    for (int i = 1; i < n; i++) {
      if (a[i].x != a[i - 1].x) rk++;
      a[i]._rank = rk;
    }
    sort(a, a + n, cmppos);
    for (int i = 0; i < n; i++) {
      long long tmp = ((sum(a[i]._rank) * a[i].x) % MOD + a[i].x) % MOD;
      add(a[i]._rank, (tmp - b[a[i]._rank] + MOD) % MOD);
      b[a[i]._rank] = tmp;
    }
    long long res = (sum(rk)) % MOD;
    printf("%I64d\n", res);
  }
}
