#include <bits/stdc++.h>

using namespace std;

long long get(long long x) {
  string s = bitset<100>(x).to_string();
  int ans = 0;
  int cur = 0;
  for (int i = 0; i < 100; i++)
    if (s[i] == '1') cur++;
  	else {
      ans += min(cur, 2);
      cur = 0;
    }
  ans += min(cur, 2);
  return ans;
}

long long get(long long x, long long y, int jumps) {
  x <<= jumps;
  long long diff = x - y;
  if (diff < 0) diff = -diff;
  long long rem = diff >> jumps;
  return min(rem + get(diff - (rem << jumps)),
          rem + 1 + get(((rem + 1) << jumps) - diff));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long x, y;
  cin >> x >> y;
  long long ans = max(x, y) - min(x, y);
  for (int i = 0; (x << i) <= (y << 2); i++)
    ans = min(ans, i + get(x, y, i));
  cout << ans << '\n';
  return 0;
}

#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <algorithm>
#include <iostream>
using namespace std;
#define f(x,y,z) for(int x=y;x<=z;++x)
#define d(x,y,z) for(int x=y;x>=z;--x)
typedef long long ll;
ll n, ans = 1, a[100001];
const int mod = 1e9+7;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    f(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    d(i,n,2) a[i] -= a[i-1];
    f(i,1,n) ans = ans*(a[i]+1)%mod;
    cout << ans << '\n';
}