PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CCBCHBAHAI0000018. Khoảng cách giữa hai phần tử theo chỉ số (Distance Between Two Indexed Elements)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Khoảng cách giữa hai phần tử theo chỉ số (Distance Between Two Indexed Elements)

Distance Between Two Indexed Elements

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

You are given an integer array aa of length nn, indexed from 00 to n−1n-1, and two distinct valid indices i,ji,j. In this PHOJ specification, the distance between the two indexed elements is defined as the absolute difference of their values:

D=∣ai−aj∣.D = |a_i-a_j|.

Compute DD.

Input

  • The first line contains three integers nn, ii, and jj. Indices i,ji,j are 0-based.
  • The second line contains exactly nn integers a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}.

Output

Print one integer D=∣ai−aj∣D=|a_i-a_j|.

Subtasks

Subtask 1 (20 points): 2≤n≤102 \le n \le 10, i=0i=0, j=n−1j=n-1, −9≤at≤9-9 \le a_t \le 9.

Subtask 2 (30 points): 2≤n≤202 \le n \le 20, 0≤i<j<n0 \le i<j<n, 0≤at≤1040 \le a_t \le 10^4.

Subtask 3 (50 points): 2≤n≤10002 \le n \le 1000, 0≤i,j<n0 \le i,j<n, i≠ji\ne j, −109≤at≤109-10^9 \le a_t \le 10^9.

Examples

Input

5 1 4
8 6 7 5 -3

Output

9

Explanation

The indices are i=1i=1 and j=4j=4. We have a1=6a_1=6 and a4=−3a_4=-3. Thus

∣a1−a4∣=∣6−(−3)∣=9.|a_1-a_4|=|6-(-3)|=9.

The output is 9.