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

#GL0000026. Cộng chữ số hàng đơn vị (Add Modulo 10)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Cộng chữ số hàng đơn vị (Add Modulo 10)

Add Modulo 10

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array of nonnegative integers, an operation replaces any element aia_i with ai+(ai mod 10)a_i+(a_i\bmod10). The same index can be selected repeatedly. Decide whether all elements can become equal.

Input

First line nn; second line nn integers aia_i.

Output

Print YES if possible, otherwise NO.

Subtasks

  • Subtask 1 (20 points): 1≤n≤101 \le n \le 10; 0≤ai≤1000 \le a_i \le 100
  • Subtask 2 (30 points): 1≤n≤20001 \le n \le 2000; 0≤ai≤1060 \le a_i \le 10^{6}
  • Subtask 3 (50 points): 1≤n≤2⋅1051 \le n \le 2\cdot 10^{5}; 0≤ai≤1090 \le a_i \le 10^{9}

Examples

Input

2
6 11

Output

YES

Explanation

Update 66 to 1212 and 1111 to 1212, so both elements become equal.