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

#GL0000321. Khách sạn Hilbert (Hilbert's Hotel)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Khách sạn Hilbert (Hilbert's Hotel)

Hilbert's Hotel

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Hilbert's Hotel has exactly one room numbered kk for every integer kk, including negative integers. Initially each room is occupied by exactly one guest.

You are given nn integers a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}. Simultaneously move the guest in room kk to room

k+ak mod n,k+a_{k\bmod n},

where k mod nk\bmod n is always the remainder in [0,n−1][0,n-1], even for negative kk.

Determine whether, after all moves, every room is still occupied by exactly one guest, with no empty rooms and no collisions.

Input

Line 1 contains nn. Line 2 contains exactly nn integers a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1} in index order from 00 to n−1n-1.

Output

Print YES if each room remains occupied by exactly one guest, or NO otherwise.

Subtasks

  • Subtask 1 (20 points): 1≤n≤101\le n\le10; −109≤ai≤109-10^9\le a_i\le10^9 for all 0≤i<n0\le i<n.
  • Subtask 2 (30 points): 1≤n≤50001\le n\le5000; −109≤ai≤109-10^9\le a_i\le10^9 for all 0≤i<n0\le i<n.
  • Subtask 3 (50 points): 1≤n≤2⋅1051\le n\le2\cdot10^5; −109≤ai≤109-10^9\le a_i\le10^9 for all 0≤i<n0\le i<n.

Examples

Example 1

Input

3
0 0 0

Output

YES

Explanation

Every offset is 00, so each guest stays in their original room and the assignment remains one-to-one.

Example 2

Input

2
0 1

Output

NO

Explanation

Guests in even rooms stay. The guest in room 11 moves to room 22, whose original guest does not move, causing a collision and leaving room 11 empty.