#include <bits/stdc++.h>
using namespace std;
void in(int &x) {
  register int c = getchar();
  x = 0;
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
}
const int N = 1e5 + 5, MAXVAL = 1e6;
long long mod = 1e9 + 7;
long long a[N], st[40 * N];
void update(int i, int begin, int end, int pos, int val) {
  if (begin == end)
    st[i] = val;
  else {
    int mid = begin + end >> 1;
    pos <= mid ? update(i << 1, begin, mid, pos, val)
               : update(i << 1 | 1, mid + 1, end, pos, val);
    st[i] = (st[i << 1] + st[i << 1 | 1]) % mod;
  }
}
int solve(int i, int begin, int end, int l, int r) {
  if (l <= begin && r >= end) return st[i];
  int mid = begin + end >> 1;
  if (r <= mid) return solve(i << 1, begin, mid, l, r);
  if (l > mid) return solve(i << 1 | 1, mid + 1, end, l, r);
  return (solve(i << 1, begin, mid, l, r) +
          solve(i << 1 | 1, mid + 1, end, l, r)) %
         mod;
}
int main() {
  int n, i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    long long pre = solve(1, 0, MAXVAL, 0, a[i]),
              cur = ((pre + 1) * a[i]) % mod;
    update(1, 0, MAXVAL, a[i], cur);
  }
  cout << st[1] << endl;
  return 0;
}
