#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int N, x;
int store[maxn];
int first_pos[maxn], last_pos[maxn], max_before[maxn];
map<int, bool> appear;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int m = -1;
  cin >> N >> x;
  for (register int i = 1; i < N + 1; i++) {
    cin >> store[i];
    int &num = store[i];
    if (!appear[num]) {
      appear[num] = true;
      first_pos[num] = i;
    }
    last_pos[num] = i;
    m = max(m, num);
    max_before[num] = m;
  }
  first_pos[x + 1] = maxn;
  int min_suffix = 1, pos = maxn;
  for (register int i = x; i >= 1; i--) {
    if (!first_pos[i]) continue;
    if (last_pos[i] > pos) {
      min_suffix = i;
      break;
    }
    pos = min(pos, first_pos[i]);
  }
  pos = last_pos[1];
  int cur_lim = max(min_suffix, max_before[1]);
  long long ans = x - min_suffix + 1;
  for (register int i = 2; i < x + 1; i++) {
    if (!first_pos[i]) {
      ans += x - max(cur_lim, i) + 1;
      continue;
    }
    if (pos > first_pos[i]) {
      ans += x - max(min_suffix, max_before[1]) + 1;
      break;
    }
    cur_lim = max(cur_lim, max_before[i]);
    ans += x - cur_lim + 1;
    pos = max(pos, last_pos[i]);
  }
  cout << ans << endl;
  return 0;
}
