#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int MOD = 1e9 + 7;
int n, mx;
int a[N], fw[10 * N], last[10 * N];
void upd(int i, int v) {
  for (; i <= mx; i += i & -i) fw[i] = (fw[i] + v) % MOD;
}
int get(int i) {
  int ans = 0;
  for (; i >= 1; i -= i & -i) ans = (ans + fw[i]) % MOD;
  return ans;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  mx = *max_element(a + 1, a + 1 + n);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int memo = (1ll * get(a[i]) * a[i] % MOD + a[i]) % MOD;
    upd(a[i], (memo - last[a[i]] + MOD) % MOD);
    last[a[i]] = memo;
  }
  cout << get(mx) << "\n";
  return 0;
}
