#include <bits/stdc++.h>
using namespace std;
long long tree[4 * 1000001];
void build(long long node, long long start, long long end) {
  if (start == end) {
    tree[node] = 0;
  } else {
    long long mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    tree[node] = tree[2 * node] + tree[2 * node + 1];
  }
}
long long query(long long node, long long start, long long end, long long l,
                long long r) {
  if (r < start or end < l) {
    return 0;
  }
  if (l <= start and end <= r) {
    return tree[node];
  }
  long long mid = (start + end) / 2;
  long long p1 = query(2 * node, start, mid, l, r);
  long long p2 = query(2 * node + 1, mid + 1, end, l, r);
  return (p1 + p2) % 1000000007;
}
void update(int node, int start, int end, int idx, int val) {
  if (start == end) {
    tree[node] = val;
  } else {
    long long mid = (start + end) / 2;
    if (start <= idx and idx <= mid) {
      update(2 * node, start, mid, idx, val);
    } else {
      update(2 * node + 1, mid + 1, end, idx, val);
    }
    tree[node] = (tree[2 * node] + tree[2 * node + 1]) % 1000000007;
  }
}
int main() {
  long long n;
  cin >> n;
  long long a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  build(1, 1, 1000001);
  for (int i = 1; i <= n; i++) {
    long long x = query(1, 1, 1000001, 1, a[i]);
    long long y = (x * a[i]) % 1000000007;
    y = (y + a[i]) % 1000000007;
    update(1, 1, 1000001, a[i], y);
  }
  long long c1 = query(1, 1, 1000001, 1, 1000001);
  c1 = c1 % 1000000007;
  cout << c1;
  return 0;
}
