#include <bits/stdc++.h>
using namespace std;
const int nmax = 100010;
const int mod = 1000000007;
int n, a[nmax], prv[nmax];
map<int, int> last;
int aib[nmax], nr[nmax];
vector<pair<int, int> > v;
int lsb(int x) { return (x & (x - 1)) ^ x; }
void update(int pos, int val) {
  for (; pos <= n; pos += lsb(pos)) aib[pos] = (aib[pos] + val) % mod;
}
int query(int pos) {
  int now = 0;
  for (; pos; pos -= lsb(pos)) now = (now + aib[pos]) % mod;
  return now;
}
int main() {
  scanf("%i", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%i", &a[i]);
    if (last.count(a[i]))
      prv[i] = last[a[i]];
    else
      prv[i] = 0;
    last[a[i]] = i;
    v.push_back(make_pair(a[i], i));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    int pos = v[i].second, start;
    start = (prv[pos] == 0 ? 1 : prv[pos]);
    nr[pos] = (query(pos - 1) - query(start - 1) + mod) % mod;
    if (nr[pos] < 0) nr[pos] += mod;
    if (prv[pos] == 0) nr[pos] = (nr[pos] + 1) % mod;
    nr[pos] = (1LL * nr[pos] * v[i].first) % mod;
    update(pos, nr[pos]);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans = (ans + nr[i]) % mod;
  printf("%d\n", ans);
}
