#include <bits/stdc++.h>
using namespace std;
int aib[100010];
int n;
void update(int poz, int val) {
  for (poz; poz <= n; poz += ((poz) & -(poz)))
    aib[poz] = (aib[poz] + val) % 1000000007;
}
int query(int poz) {
  int ans = 0;
  for (poz; poz; poz -= ((poz) & -(poz))) ans = (ans + aib[poz]) % 1000000007;
  return ans;
}
int main() {
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 1; i <= n; i++) {
    cin >> v[i - 1].first;
    v[i - 1].second = i;
  }
  sort(v.begin(), v.end());
  int vlast = -1, plast = 0;
  int r = 0;
  for (auto i : v) {
    if (i.first != vlast) plast = 1;
    int ans = (query(i.second) - query(plast - 1) + 1000000007) % 1000000007;
    ans = 1LL * (ans + (vlast != i.first)) * i.first % 1000000007;
    vlast = i.first, plast = i.second;
    r = (r + ans) % 1000000007;
    update(i.second, ans);
  }
  cout << r << '\n';
  return 0;
}
