#include <bits/stdc++.h>
using namespace std;
const int inf = 100009;
int sgt[inf * 4];
int num[inf];
int z[inf];
int idx[inf];
multimap<int, int> m;
const int mod = 1000000007;
void build(int x, int l, int r) {
  if (l == r) {
    idx[l] = x;
    return;
  }
  build(x + x, l, (l + r) / 2);
  build(x + x + 1, (l + r) / 2 + 1, r);
}
void update(int x, int v) {
  x = idx[x];
  sgt[x] = v;
  x /= 2;
  while (x) {
    sgt[x] = (sgt[x + x] + sgt[x + x + 1]) % mod;
    x /= 2;
  }
}
int s, e;
int query(int x, int l, int r) {
  if (s <= l && e >= r) return sgt[x];
  int a = 0, b = 0;
  if ((l + r) / 2 >= s) a = query(x + x, l, (l + r) / 2);
  if ((l + r) / 2 + 1 <= e) b = query(x + x + 1, (l + r) / 2 + 1, r);
  return (a + b) % mod;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &num[i]);
    m.insert(make_pair(num[i], i));
  }
  int sel = 0, lst = -1;
  for (map<int, int>::iterator it = m.begin(); it != m.end(); ++it) {
    if (it->first != lst && lst != -1) ++sel;
    lst = it->first;
    z[it->second] = sel;
  }
  int sol = 0, k, w;
  build(1, 0, n - 1);
  for (int i = 0; i < n; ++i) {
    s = 0;
    e = z[i];
    k = query(1, 0, n - 1);
    w = ((long long)k * (long long)num[i] + (long long)num[i]) % mod;
    sol = (sol - sgt[idx[z[i]]] + mod) % mod;
    sol = (sol + w) % mod;
    update(z[i], w);
  }
  printf("%d\n", sol);
}
