#include <bits/stdc++.h>
using namespace std;
map<int, int> maping;
long long vt[1000007], tree[4 * 1000007], unq = 0;
void update(int node, int b, int e, int x, int y, long long val) {
  if (e < x || b > y) {
    return;
  }
  if (b >= x && e <= y) {
    tree[node] = (val) % 1000000007;
    return;
  }
  int mid = (b + e) / 2, lson = 2 * node, rson = lson + 1;
  update(lson, b, mid, x, y, val);
  update(rson, mid + 1, e, x, y, val);
  tree[node] = (tree[lson] + tree[rson]) % 1000000007;
}
int query(int node, int b, int e, int x, int y) {
  if (e < x || b > y) {
    return 0;
  }
  if (b >= x && e <= y) {
    return tree[node];
  }
  int mid = (b + e) / 2, lson = 2 * node, rson = lson + 1;
  return (query(lson, b, mid, x, y) + query(rson, mid + 1, e, x, y)) %
         1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> vt[i];
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long int ret = query(1, 1, 1000000, 1, vt[i]);
    long long int cur = (ret * vt[i]) % 1000000007 + vt[i];
    update(1, 1, 1000000, vt[i], vt[i], cur);
  }
  for (int i = 1; i <= 1000000; i++) {
    ans = (ans + query(1, 1, n, i, i)) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
