magic index with distinct numbers