#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
int seg[4 * int(1e5 + 10)] = {0}, ind[int(1e5 + 10)];
long long int a[int(1e5 + 10)], dp[int(1e5 + 10)];
std::vector<pair<int, int> > v;
int n;
void update(int n, int it, int f, int q1, long long int value) {
  if (it == q1) {
    seg[n] = (seg[n] + value) % int(1e9 + 7);
    return;
  }
  int m = (it + f) / 2;
  if (q1 > m)
    update(n * 2 + 1, m + 1, f, q1, value);
  else {
    seg[n * 2 + 1] = (seg[n * 2 + 1] + value) % int(1e9 + 7);
    update(n * 2, it, m, q1, value);
  }
}
int query(int n, int it, int f, int q) {
  if (it == f) return seg[n];
  int m = (it + f) / 2;
  if (q <= m) return (query(n * 2, it, m, q) + seg[n]) % int(1e9 + 7);
  return (query(n * 2 + 1, m + 1, f, q) + seg[n]) % int(1e9 + 7);
}
int bnr(int q) {
  int it = 1, f = n, m;
  while (it != f) {
    m = (it + f) / 2;
    if (v[m].first >= q)
      f = m;
    else
      it = m + 1;
  }
  return f;
}
int main() {
  int q;
  cin >> n;
  v.push_back(make_pair(0, 0));
  for (int i = int(1); i <= (int)n; i++) {
    scanf("%d", &q);
    ;
    a[i] = q;
    v.push_back(make_pair(a[i], i));
  }
  std::map<int, int> sub;
  sort(v.begin() + 1, v.end());
  for (int i = int(1); i <= (int)n; i++) ind[v[i].second] = i;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    dp[i] = query(1, 1, n, ind[i]);
    dp[i] = (a[i] + (a[i] * dp[i]) % int(1e9 + 7)) % int(1e9 + 7);
    dp[i] = (dp[i] - sub[a[i]] + int(1e9 + 7)) % int(1e9 + 7);
    sub[a[i]] = (sub[a[i]] + dp[i] + int(1e9 + 7)) % int(1e9 + 7);
    int low = bnr(a[i]);
    update(1, 1, n, low, dp[i]);
    ans = (ans + dp[i]) % int(1e9 + 7);
  }
  printf("%d\n", ans);
  return 0;
}
