#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1000000007;
long long qp(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};
mint operator+(mint a, mint b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mod : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % mod; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }
template <class T>
inline bool scan(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void out(T x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
int n;
mint a[maxn];
mint dp[maxn];
mint pre[maxn * 10];
mint val[maxn * 10];
void add(int pos, mint x) {
  while (pos < maxn * 10) {
    val[pos] += x;
    pos += pos & -pos;
  }
}
mint query(int pos) {
  mint res = 0;
  while (pos > 0) {
    res += val[pos];
    pos -= pos & -pos;
  }
  return res;
}
int main() {
  scan(n);
  for (int i = 1; i <= n; ++i) scan(a[i].n);
  mint res = 0;
  for (int i = 1; i <= n; ++i) {
    mint tmp = query(a[i].n) * a[i] + a[i];
    dp[i] = tmp - pre[a[i].n];
    pre[a[i].n] = tmp;
    res += dp[i];
    add(a[i].n, dp[i]);
  }
  out(res.n);
  putchar('\n');
  return 0;
}
