#include <bits/stdc++.h>
using namespace std;
long long n, m = 0;
long long s[1000010];
long long a[100010];
long long pre[1000010];
long long lowbit(long long x) { return x & (-x); }
long long get_sum(long long x) {
  long long i;
  long long sum = 0;
  for (i = x; i > 0; i -= lowbit(i)) {
    sum = (sum + s[i]) % 1000000007;
  }
  return sum;
}
void change(long long x, long long y) {
  long long i;
  for (i = x; i <= m; i += lowbit(i)) {
    s[i] = (s[i] + y) % 1000000007;
  }
}
int main() {
  ios::sync_with_stdio(0);
  long long i, j, k;
  memset(s, 0, sizeof(s));
  memset(pre, 0, sizeof(pre));
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    m = max(m, a[i]);
  }
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    long long tem = (get_sum(a[i]) * a[i] + a[i]) % 1000000007;
    ans = (ans + tem - pre[a[i]]) % 1000000007;
    change(a[i], tem - pre[a[i]]);
    pre[a[i]] = tem;
  }
  if (ans < 0) ans += 1000000007;
  cout << ans << endl;
  return 0;
}
