#include <bits/stdc++.h>
using namespace std;
long long dp[100003], last[1000003], ans, a[100003], mx, t[1000003];
int n;
void add(int pos, long long k) {
  while (pos <= mx) {
    t[pos] = (t[pos] + k) % 1000000007;
    pos += pos & -pos;
  }
}
long long query(int pos) {
  long long ret = 0;
  while (pos) {
    ret = (ret + t[pos]) % 1000000007;
    pos -= pos & -pos;
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", a + i), mx = max(mx, a[i]);
  for (int i = 1; i <= n; i++) {
    dp[i] =
        (1000000007 + (query(a[i]) * a[i] % 1000000007 + a[i]) % 1000000007 -
         last[a[i]]) %
        1000000007;
    last[a[i]] = (query(a[i]) * a[i] % 1000000007 + a[i]) % 1000000007;
    ans = (ans + dp[i]) % 1000000007;
    add(a[i], dp[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
