#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
const int maxm = 1000000 + 5;
int a[maxn];
long long dp[maxm];
int m;
inline int lowbit(int x) { return x & -x; }
long long sum(int x) {
  long long ret = 0;
  while (x > 0) {
    ret = (ret + dp[x]) % 1000000007;
    x -= lowbit(x);
  }
  return ret;
}
void add(int x, long long d) {
  while (x <= m) {
    dp[x] = (dp[x] + d + 1000000007) % 1000000007;
    x += lowbit(x);
  }
}
int query(int L, int R) {
  return (sum(R) - sum(L - 1) + 1000000007) % 1000000007;
}
void setv(int x, long long d) {
  add(x, -query(x, x));
  add(x, d);
}
int main(int argc, char *argv[]) {
  int n;
  int mx = 0;
  scanf("%d", &n);
  for (int i = (0); i <= (n - 1); i++) {
    scanf("%d", &a[i]);
    mx = max(mx, a[i]);
  }
  m = mx;
  memset(dp, 0, sizeof(dp));
  long long ans = 0;
  for (int i = (0); i <= (n - 1); i++) {
    long long ret = (sum(a[i]) + 1) * a[i] % 1000000007;
    setv(a[i], ret);
  }
  for (int i = (1); i <= (mx); i++) ans = (ans + query(i, i)) % 1000000007;
  cout << ans << endl;
  return 0;
}
