const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const input = stdin.split('\n')

const N = input[0]

const H = input[1].split(' ').map(Number)

const ans = () => {
  let streak = 0

  let max = 0

  for (let i = 0; i < N - 1; i++) {
    if (H[i] >= H[i + 1]) {
      streak++
    } else {
      max = Math.max(max, streak)
      streak = 0
    }
  }

  max = Math.max(max, streak)

  console.log(max)
}

ans()


'use strict'
function main(input: String) {
    const n: number = parseInt(input.split('\n')[0], 10);
    const hs: number[] = input.split('\n')[1].split(' ').map(h => parseInt(h, 10));
    let r: number = 0;
    for (let i = 0; i < n; i++) {
        let current = 0;
        for (let j = i; j <= n-(i+1); j++) {
            if (hs[j] >= hs[j+1]) {
              continue;
            }
            current++;
        }
        if (current > r) {
            r = current;
        }
    }
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const solve = (n) => {
  // ...
  let cnt = 0
  let max = 0
  let z = []
  n.map((r, i) => {
    if (i == 0) {
      z[i] = 0
      return
    }
    let before = n[i - 1]
    if (r > before) {
      z[i] = 0
    } else {
      z[i] = z[i - 1] + 1
      max = Math.max(z[i], max)
    }
  })
  // console.log(z)
  return max
}
const main = (input) => {
  const [h, r] = input.split("\n")
  return solve(r.split(" "))
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}


import { readFileSync } from 'fs'
function main() {
  const input: string = readFileSync('/dev/stdin', 'utf8')
  const [N, line] = input.split('\n')
  const array = line.trim().split(' ').map(v => parseInt(v))
  let count = 0

  for (let i = 0; i < array.length; i++) {
    if (count >= array.length - i) {
      break
    }
    if (i === 0
      || (count >= 1 && array[i] > array[i - 1] && array[i] >= array[i + 1])
      || (count >= 2 && array[i] > array[i - 1] && array[i] >= array[i + 1] && array[i + 1] >= array[i + 2])
      || (array[i] > array[i - 1] && array[i] >= array[i + 1] && array[i + 1] >= array[i + 2] && array[i + 2] >= array[i + 3])
      ) {
      let localCount = 0
      const thisArray = array.slice(i)
      for (let j = 0; j < thisArray.length; j++) {
        if (thisArray[j] >= thisArray[j + 1]) {
          localCount++
        } else {
          break
        }
      }
      if (localCount > count) count = localCount
    }
  }
  console.log(count)
}
main()


n=int(input())
l=list(map(int,input().split()))
a=max(l)
b=sum(l)-a
if a<b:
    print("Yes")
else:
    print("No")


n = int(input())
l = [int(i) for i in input().split()]
l.sort(reverse=True)
if l[0] < sum(l[1:]):
    print("Yes")
else:
    print("No")


N = int(input())
L = list(map(int, input().split()))

l_max = max(L)
if l_max < sum(L) - l_max:
    print('Yes')
else:
    print('No')


# B Polygon
N = int(input())
L = list(map(int, input().split()))
mx = L.pop(L.index(max(L)))
if mx > sum(L):
    print("Yes")
else:
    print("No")
pass


n = int(input())
l = list(map(int, input().split()))

terms = (max(l) - (sum(l) - max(l)))

if terms:
    print('Yes')
else:
    print('No')


#ABC117B
n = int(input())
l = [int(input()) for i in range(n)]
print("Yes" if max(l) >= (sum(l)-max(l)) else "No")


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String[] sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);

    s = r.readLine();
    sl = s.split(" ");
    int max = 0;
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
      int z = Integer.parseInt(sl[i]);
      max = Math.max(z, max);
      sum += z;
    }

    System.out.println(max < (sum - max) ? "Yes" : "No");
  }

}


import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf =
            new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(bf.readLine());
        String[] str = bf.readLine().split(" ");
        int max = 0,
            sum = 0;
        for(int i = 0; i < N; i++){
            int value = Integer.parseInt(str[i]);
            sum += value;
            if(max < value){
                max = value;
            }
        }
        if(sum - max > max){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }
}


import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {

	final boolean isDebug = false;
	String fileName = "input.txt";
	FastScanner sc;
	//PrintWriter out;
	final int MOD = 1000000007;
	final int INF = Integer.MAX_VALUE / 2;

	/* solve */
	void solve(){
		int N = sc.nextInt();
		int[] L = new int[N];
		int sum = 0;
		int max = 0;
		for(int i = 0; i < N; i++){
			L[i] = sc.nextInt();
			sum += L[i];
			max = Math.max(max, L[i]);
		}

		if(max < sum - max) System.out.println("Yes");
		else System.out.println("No");

	}
	/* end solve */

	/* main */
	public static void main(String[] args) throws IOException {
		new Main().m();
	}

	void m() throws IOException {
		long S = System.currentTimeMillis();
		sc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);
		//out = new PrintWriter(System.out);
		solve();
		//out.flush();
		long G = System.currentTimeMillis();
		if(isDebug){
			System.out.println("---Debug---");
			System.out.printf("%7d ms", (G-S));
		}
	}
	/* end main */
}
/* end Main */

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		int sum = 0;

		Scanner sc = new Scanner (System.in);
		int[] a = new int[sc.nextInt()];

		for(int i = 0; i < a.length; i++)
		{
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		for(int i = 0; i < a.length - 1; i++)
		{
			sum = sum + a[i];
		}

		if(a[a.length] > sum){
			System.out.println("Yes");
		} else
		{
			System.out.println("No");
		}

	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		int sum = 0;

		Scanner sc = new Scanner (System.in);
		int[] a = new int[sc.nextInt()];

		for(int i = 0; i < a.length; i++)
		{
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		for(int i = 0; i < a.length - 1; i++)
		{
			sum = sum + a[i];
		}

		if(a[1] > sum){
			System.out.println("Yes");
		} else
		{
			System.out.println("No");
		}

	}
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner (System.in);
		int temp = 0;
		int x = 0;
		int sum = 0;

		for(int i = 0; i < sc.nextInt(); i++)
		{
			x = sc.nextInt();
			if(x > temp)
			{
				temp = x;
			} else {
				sum = sum + x;
			}
		}

		if(x > sum)
		{
			System.out.println("Yes");
		} else
		{
			System.out.println("No");
		}

	}

}


#include <cstdio>
#include <algorithm>
using namespace std;

int n, mx, sum;

int main()
{
	scanf("%d", &n);
	for (int i = 1, x; i <= n; i ++)
	{
		scanf("%d", &x);
		mx = max(mx, x);
		sum += x;
	}
	puts(mx * 2 < sum ? "Yes" : "No");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    sort(ALL(a));
    int l = a.back();
    int s = accumulate(begin(a), end(a) - 1, 0LL);
    if (l < s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return (0^_^0);
}


#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>

int main(void) {
	using namespace std;
	int N, a;
	int b = 0;
	vector<int>vec;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		vec.push_back(a);
	}
	sort(vec.begin(), vec.end());

	for (int i = 0; i < N - 1;i++) {
		b += vec[i];
	}
	if (vec[N - 1] < b) {
		cout << "Yes" << endl;
	}
	else if (vec[N - 1] >= b) {
		cout << "No" << endl;
	}
}


#include<stdio.h>
#define size 115
int main()
{
	int N,max=-1,i,l[size],total=0;
	scanf("%d",&N);
	if(N>=3)
	{
	for(i=0;i<N;i++)
		{
			scanf("%d",&l[i]);
			if(l[i]>max&&l[i]>0)
				max=l[i];
			else
				{
				}
		}
	for(i=0;i<N;i++)
		{
			if(l[i]!=max&&l[i]>0)
				{
					total+=l[i];
				}
			else
				{
				}
		}
	if(max<total)
		{
			printf("Yes\n");
		}
	else
		{
			printf("No\n");
		}
	}
	else
		{
			printf("No\n");
		}
	return 0;
}


#include<stdio.h>
#define size 115
int main()
{
	int N,max=0,i,l[size];
	long long total=0;
	scanf("%d",&N);
	if(N>=3)
	{
	for(i=1;i<=N;i++)
		{
			scanf("%d",&l[i]);
			if(l[i]>max)
				max=l[i];
		}
	for(i=1;i<=N;i++)
		{
			if(l[i]!=max)
				{
					total+=l[i];
				}
		}
	if(max<total)
		{
			printf("Yes\n");
		}
	else
		{
			printf("No\n");
		}
	}
	else
		{
			printf("No\n");
		}
	return 0;
}


#include<stdio.h>
#define size 115
int main()
{
	int N,max=0,i,l[size];
	long long total=0;
	scanf("%d",&N);
	if(N>=3)
	{
	for(i=1;i<=N;i++)
		{
			scanf("%d",&l[i]);
		}
	for(i=1;i<=N;i++)
		{
			if(l[i]>max)
				max=l[i];
			else
				{
				}
		}
	for(i=1;i<=N;i++)
		{
			if(l[i]!=max)
				{
					total+=l[i];
				}
			else
				{
				}
		}
	if(max<total)
		{
			printf("Yes\n");
		}
	else
		{
			printf("No\n");
		}
	}
	else
		{
			printf("No\n");
		}
	return 0;
}


#include<stdio.h>

int main(void)
{
  int n;
  scanf("%d",&n);

  int l[n],msl=0,all=0,i;
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
    if(msl<l[i])
      msl=l[i];
    all += l[i];
  }

  all -= msl;

  if(all>msl)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
int main()
{
  int *x,n,i,a,sum;
  scanf("%d",&n);
  x = (int*)malloc(sizeof(int) * n);
  for(i=0;i < n;i++){
    scanf("%d",x+i);
  }

  for(i=0;i <= n-2;i++){
    if (x[i] > x[i+1]){
      a = x[i+1];
      x[i+1] = x[i];
      x[i] = a;
    }
  }
  sum = 0;
  for (i=0;i < n-1;i++){
    sum += x[i];
  }
  if (sum > x[n-1]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


#include<stdio.h>

int main(void)
{
int n,l[101],i,lmax=0,lsum=0;

scanf("%d",&n);

for(i=0;i<n;i++)
{
scanf("%d",&l[i]);

  if(lmax<l[i])
  {
    lmax = l[i];
  }

lsum += l[i];
}

if(lmax<lsum-lmax)
{
printf("Yes");
}
else
{
  printf("No");
}

  return 0;
}


#include<stdio.h>
int main()
{

    int a,b,i,j,k=1,z,max,p=0,q=0;
    scanf("%d",&a);
    int ara[a+10];
    for(i=0;i<a;i++)
    {
        scanf("%d",&ara[i]);
    }
    max=ara[0];
    for(j=0;j<a;j++)
    {

        if(ara[j]>max)
        {
            max=ara[j];
        }
    }
    for(i=0;i<a;i++)
    {
        if(ara[i]!=max)
        {
            p=p+ara[i];
        }
    }
    if(p>max)
    {
        printf("Yes\n");
    }
    else
        {
            printf("No\n");
        }

}


#include<stdio.h>
int main()
{
    int n,i,sum=0,max=0;
    scanf("&d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",a[i]);

    }
    for(i=0;i<n;i++)
    {
        sum=+a[i];
        max=a[i];

    }
    if((sum-max)>max)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}


#include<stdio.h>
#define SIZE 1000
int main()
{
    long long int i, n, a[SIZE], max, sum=0;
    scanf("%lld\n", &n);
    for(i=0;i<=n-1;i++)
    {
        scanf("%lld", &a[i]);
        max = a[0];
        if(a[i]>= max)
        {
            max = a[i];
        }
        sum += a[i];
    }
    sum = sum - max;
    if(max < sum)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}


/**
 *
 * @param {string} input
 */
function main(input) {
  var inputList = input.split("\n");
  var n = Number(inputList[0]);
  var list = inputList[1].split(" ");
  var max = 0;
  var sum = 0;
  for(i=0; i<n; i++){
    if(max < Number(list[i])){
      max = Number(list[i]);
    }
    sum += Number(list[i]);
  }

  if(max < (sum-max)){
    console.log("Yes");
  }else{
    console.log("No");
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(string){
  var line2 = string.split('\n')[1]
  var listInt = line2.split(' ').map(v=>+v)
  var head  = listInt.sort((a,b)=>a<b?-1:1).slice(0,-1)
  var max   =  listInt.sort((a,b)=>a<b?-1:1).slice(-1)[0]
  var headSum = head.reduce((s,v)=>s+v)
  console.log(max < headSum ? 'Yes' : 'No')
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function solve(n, nums) {
    var sum = 0, max = 0;
    nums.forEach(function (n) {
        if (max < n) {
            max = n;
        }
        sum += n;
    });
    if (max < sum - max) {
        return 'Yes';
    }
    return 'No';
}

function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split('\n')
    var n = input[0];
    var nums = input[1].split(' ').map(function(n) { return Number(n)});
    console.log(solve(n, nums));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


    let allVal = require("fs").readFileSync("/dev/stdin", "utf8").split("\n")[1]
    let mstVal = Math.max(...allVal)
    let mstPos = allVal.indexOf(mstVal + "")
    allVal.splice(mstPos, 1)
    console.log(allVal.reduce((cur, prev) => cur + +prev, 0) > mstVal ? "Yes" : "No");


function main(input) {
    let allVal = input[1].split(" ")
    let mstVal = Math.max(...allVal)
    let mstPos = allVal.indexOf(mstVal + "")
    allVal.splice(mstPos, 1)
    return allVal.reduce((cur, prev) => cur + +prev, 0) > mstVal ? "Yes" : "No"
}


const input = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
console.log(input)


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	l := make([]int, n)

	max := 0
	sum := 0
	for i := range l {
    	fmt.Scan(&l[i])
		sum += l[i]
		if l[i] > max {
			max = l[i]
		}
	}
	sum -= max

	if max < sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	var sum, max int
	for i := 0; i < N; i++ {
		L := nextInt()
		sum += L
		max = MaxOf(max, L)
	}
	if max < sum-max {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	Ls := nextInts(N)
	sum := Sum(Ls...)
	max := Max(Ls...)
	if sum-max > max {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func Sum(slice ...int) int {
	sum := 0
	for _, v := range slice {
		sum += v
	}
	return sum
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}


package main

import (
	"fmt"
)

func main() {
	var n,l,max,sum int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&l)
		if l > max {
			max = l
		}
		sum += l
	}

	if max > sum - max {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ls := make([]int, n)
	for i := range ls {
		fmt.Scan(&ls[i])
	}
	maxl := ls[0]
	t := ls[0]
	for i := 1; i < n; i++ {
		t += ls[i]
		if ls[i] > ls[i-1] {
			maxl = ls[i]
		}
	}
	if t-maxl > maxl {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ls := make([]int, n)
	for i := range ls {
		fmt.Scan(&ls[i])
	}
	maxl := ls[0]
	t := 0
	for i := 1; i < n; i++ {
		t += ls[i]
		if ls[i] > ls[i-1] {
			maxl = ls[i]
		}
	}
	if t-maxl > maxl {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


gets
l = gets.split.map(&:to_i)
l.sort!.reverse!
max = l[0]
l.shift()
sum = l.inject(:+)

puts max < sum ? "Yes" : "No"


_ = gets
nums = gets.split.map(&:to_i).sort
puts nums[-1] < nums[0..-2].inject(&:+) ? 'Yes' : 'No'


N = gets.to_i
L = gets.split.map(&:to_f).sort
puts L[-1] < L[0..-2].inject(:+) ? "Yes" : "No"


n,*a=`dd`.split.map(&:to_i)
s=a.sum
a.each do |i|
  if s-i<i
    puts 'No'
    exit
  end
end
puts 'Yes'


#標準入力を取得
input_n = gets.to_i
input_array = gets.split(" ").map(&:to_i)

#辺の長さの配列を昇順にソート
input_array = input_array.sort!

#最大長さの辺以外の合計を格納する変数を初期化
amountLength = 0

#0以上n-1未満を繰り返し
(0...input_n-1).each do |i|
  amountLength += input_array[i]　#最大長さ以外の辺の長さを加算
end

#最大長さ < その他の辺の長さ　を判定
if input_array[input_n-1] < amountLength
  puts "Yes"
else
  puts "No"
end


N, *l = $stdin.read.split(/\s/).map(&:to_i)
l.sort!
lmax = l.pop
lrest = l.reduce(0) {|s, a| s + a }
puts (lmax < lrest) ? 'YES' : 'NO'


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        ll: [u32;n]
    }
    let mut ll = ll;
    ll.sort();
    ll.reverse();
    if ll.iter().skip(1).sum::<u32>() > ll[0] {
        println!("Yes");
    } else {
        println!("No");
    }
}


use std::io::*;
use std::str::FromStr;

/*
The read function reads a string according to each one.
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let n: i32 = read();
    let mut max: i32 = 0;
    let mut sum: i32 = 0;
    for _i in 0..n{
	let number: i32 = read();
	if max < number {
	    max = number;
	}
	sum += number;
    }
    if 2*max < sum {
	println!("Yes");
    }else{
	println!("No");
    }
}


// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"4
3 8 5 1
" => r"Yes",

r"4
3 8 4 1
" => r"No",

r"10
1 8 10 5 8 12 34 100 11 3
" => r"No"
}

use std::cmp;
use std::cmp::max;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: i32,
        l: [i32; n]
    }

    let mut ans = 0;
    let mut maxnum = 0;
    for i in 0..l.len() {
        ans += l[i];
        maxnum = cmp::max(l[i], maxnum);
    }

    if maxnum < ans - maxnum {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, l: [usize; n]};
    let mut l: Vec<usize> = l;

    let mut l_c = l.clone();
    let mut max = l_c.iter().max().unwrap();

    l.sort();
    l.pop();
    l.reverse();

    let mut sum = 0;
    let mut b = false;

    for l_i in l.iter() {
        sum += l_i;
        if sum >= *max {
            b = true;
            break;
        }
    }

    if b {
        println!("Yes")
    } else {
        println!("No")
    }
}


use std::io::{stdin, Read};
use std::str::FromStr;
use std::cmp::Reverse;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: i64 = read().unwrap();
    let mut ls: Vec<i64> = Vec::new();
    for _i in 0..n {
        let l: i64 = read().unwrap();
        ls.push(l);
    }
    ls.sort_by_key(|&x| Reverse(x));
    let maxl: i64 = ls[0];
    let suml = ls.iter().skip(1).fold(0, |acc, i| acc + i);
    if maxl < suml {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn usize() -> usize {
    read()
}

fn vec_usize(n: usize) -> Vec<usize> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(usize())
    }
    vec
}

fn main() {
    let n = usize();
    let ls = vec_usize(n).into_iter();

    let max = ls.clone().max().unwrap();
    let sum: usize = ls.clone().sum();

    if max * 2 < sum {
        println!("YES");
    } else {
        println!("NO");
    }
}


import Foundation

let _ = readLine()!
var input = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

var sum = 0
for i in input {
    sum += i
}

let maxL = input.maxElement()!

if maxL < sum - maxL {
    print("Yes\n")
} else {
    print("No\n")
}


import Foundation

let N = Int(readLine()!)
var input = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

input.sortInPlace { $0 > $1 }

var sum = 0
for i in input {
    sum += i
}

if input[0] < sum - input[0] {
    print("Yes\n")
} else {
    print("No\n")
}


import Foundation

let N = Int(readLine()!)!
var input = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

input.sortInPlace()

var sum = 0
for i in input {
    sum += i
}

if input[N-1] < sum - input[N-1] {
    print("Yes\n")
} else {
    print("No\n")
}


let N: Int = Int(readLine()!)!
var Ls: [Int] = readLine()!.split(separator: " ").map { Int($0)! }

Ls.sort()
print(Ls.dropLast().reduce(0, +) > Ls.last! ? "No" : "Yes")


import Foundation

let N = Int(readLine()!)
var input = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

input.sortInPlace()

var sum = 0
for i in input {
    sum += i
}

if input[N-1] < sum - input[N-1] {
    print("Yes\n")
} else {
    print("No\n")
}


import Foundation

let N = Int(readLine()!)
var input = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

input.sortInPlace { $0 > $1 }

var sum = 0
for i in input {
    sum += i
}

print(input)

if input[0] < sum - input[0] {
    print("Yes\n")
} else {
    print("No\n")
}


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = stdin.split('\n')[0]

const l = stdin.split('\n')[1].split(' ').map(Number)

const max = Math.max(...l)

const maxi = l.indexOf(max)

l.splice(maxi, 1)

const sum = l.reduce((p,c)=> p += c)

if(sum > max){
  console.log('Yes')
} else {
  console.log('No')
}


export class Main {
  static main(input: string): string {
    const [n, ls] = input.split("\n");
    const nN = Number(n);
    const lList = ls.split(" ").map(Number);
    lList.sort((a, b) => b - a);
    const max = lList[0];
    let tmp = 0;
    for (let i = 1, len = lList.length; i < len; i++) {
      tmp += lList[i];
      if (max < tmp) {
        return "Yes"
      }
    }
    return `No`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let n=t.n()
  let nr=t.n(n)
  let m=t.max(...nr)
  t.o(m<nr.reduce((t,d)=>{return t+d})-m?'Yes':'No')
}
main()


const main = (input: string) => {
  const lines = input.trim().split("\n");
  let L = lines[1].split(" ").map(str => parseInt(str));
  const maxLength = Math.max.apply(null, L);
  let sum = 0;

  L = L.filter(l => {
    return l !== maxLength
  })

  L.forEach(l => {
    sum += l;
  })

  console.log(sum > maxLength ? "Yes" : "No")
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


const main = (input: string) => {
  const lines = input.trim().split("\n");
  const N = parseInt(lines[0])
  let L = lines[1].split(" ").map(str => parseInt(str));
  const maxLength = Math.max(...L);
  let sum = 0;
  L = L.filter(l => {
    return l !== maxLength
  })

  L.forEach(l => {
    sum += l;
  })

  console.log(sum > maxLength ? "Yes" : "No")
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


const Main = args => {
  const [_, numbers] = args.split('\n');
  const number = numbers.split(' ').map(Number);
  let sum = 0;

  const max = Math.max(...number);
  const other = number.filter(num => num !== max);
  other.map(o => (sum += parseInt(o)));
  return sum <= max ? 'No' : 'Yes';
};

const args = require('fs').readFileSync('/dev/stdin', 'utf8');
console.log(Main(args))


N = int(input())
items = []
for i in range(N):
    s, p  = input().split()
    items.append((s, int(p), i))

items = sorted(items, key=lambda x:(x[0], -x[1]))

for s, p, i in items:
    print(i+1)


n = int(input())
mise = []
for i in range(n):
    name, rate = [item for item in input().split()]
    mise.append([name, -int(rate), i+1])

mise.sort()
for mise, rate, index in mise:
    print(index)


N = int(input())
Michelin = dict()
seen = []
number = 1
for _ in range(N):
    shop,point = map(str,input().split())
    if shop not in seen:
        Michelin[shop] = [[],[]] #moscow:{[[],[]]} point,number
        Michelin[shop][0].append(int(point))
        Michelin[shop][1].append(number)
        number += 1
        seen.append(shop)
    else:
        Michelin[shop][0].append(int(point))
        Michelin[shop][1].append(number)
        number += 1
seen.sort() #店の名前が辞書順になる。
#{'khabarovsk': [[20, 40], [1, 6]], 'moscow': [[10, 60], [2, 5]], 'kazan': [[50, 35], [3, 4]]}
for shop in seen:
    while Michelin[shop][0] != []:
        shokai = max(Michelin[shop][0])
        bango = Michelin[shop][0].index(shokai)
        print(Michelin[shop][1][bango])
        Michelin[shop][0].remove(shokai)
        Michelin[shop][1].remove(Michelin[shop][1][bango])


N = int(input())
l = []
for i in range(N):
    s,p = input().split()
    l.append([s,int(p),i+1])

l = sorted(l,key = lambda x:x[1],reverse=True)
l = sorted(l,key = lambda x:x[0])

for i in range(N):
    print(l[2])


n = int(input())
tbl = []
s = []
p = []
for i in range(n):
    l = list(map(str,input().split()))
    l[1] = int(l[1])
    l2 = [l[1], l[0], i + 1]
    tbl.append(l2)
    s.append(l2[1])
    p.append(l2[0])

p.sort()
p.reverse()
tbl2 = []
for i in range(n):
    for j in range(n):
        if(tbl[j][0] == p[i]):
            tbl2.append(tbl[j])
s = list(set(s))

for i in range(len(s)):
    for j in range(len(tbl2)):
        if (tbl2[j][1] == s[i]):
            print(tbl2[j][2])


from operator import itemgetter
n = int(input())
point = []
ans = []
for i in range(n):
    a,b = input().split()
    s = [a,int(b),i+1]
    point.append(s)
s_point = sorted(point)
name = s_point[0][0]
for j in range(n):
    if s_point[j][0] == name:
        m = s_point[j]
        ans.append(m)
        if j == n-1:
            s_ans = sorted(ans,key=itemgetter(1),reverse=True)
            for k in range(len(ans)):
                print(s_ans[k][2])
            exit()
    else:
        s_ans = sorted(ans,key=itemgetter(1),reverse=True)
        for k in range(len(ans)):
            print(s_ans[k][2])
        ans = []
        m = s_point[j]
        ans.append(m)
        name = s_point[j][0]


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author maheshwari29
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        BGuidebook solver = new BGuidebook();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGuidebook {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int i, j;
            int n = in.ni();
            BGuidebook.pair p[] = new BGuidebook.pair[n];
            for (i = 0; i < n; i++) {
                String s = in.next();
                int x = in.ni();
                p[i] = new BGuidebook.pair(s, x, i);
            }
            Arrays.sort(p);
            for (i = 0; i < n; i++)
                out.println((p[i].index + 1));
        }

        static class pair implements Comparable<BGuidebook.pair> {
            int y;
            int index;
            String x;

            public pair(String x, int y, int index) {
                this.x = x;
                this.y = y;
                this.index = index;

            }

            public int compareTo(BGuidebook.pair arg0) {
                if (x.compareTo(arg0.x) < 0) return -1;
                else if (x.compareTo(arg0.x) == 0) {
                    if (y < arg0.y) return 1;
                    else if (y > arg0.y) return -1;
                    else return 0;
                } else return 1;
            }

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String ns() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return ns();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;

/** テンプレート */
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();

		PairSI[] pair = new PairSI[N];
		for(int i =0 ; i < N; i++) {
			String s = sc.next();
			int p = sc.nextInt();
			pair[i] = new PairSI(s, p, i+1);
		}

//		Pair[] a = { new Pair(0, 5), new Pair(1, 10), new Pair(2, 3) };
		Arrays.sort(pair, new Comparator<PairSI>() {
			public int compare(PairSI o1, PairSI o2) {
				if(o1.k.compareTo(o2.k) == 0) {
					return Integer.compare(o2.v, o1.v); //Java7以降
				}else {
					return o1.k.compareTo(o2.k);
				}
			}
		});

		//************************************/
		// ここから出力処理
		//************************************/
		PrintWriter out = new PrintWriter(System.out);

		for(int i = 0; i < N; i++) {
			out.println(pair[i].num);
		}

		// 最後に必ずFlush
		out.flush();
	}
}

///** テンプレート */
//public class Main {
//	final static int SSSSS = 1000000;
//
//
//	public static void main(String[] args) {
//		FastScanner sc = new FastScanner();
//		int N = sc.nextInt();
//		int K = sc.nextInt();
//
//		double ans = 0;
//		int min = Main.calc(K);
//		int count = 1;
//
//
//		if(K <= N) {
//
//			for(int i=2; i<=K-1; i++) {
//
//				 count += min / Main.calc((int)Math.ceil((double)K / i));
//
//			}
////			//deb
////			out.println(count);
//
//			ans = (double)(count+(N-K+1)*min)/(N * min);
//
//		}else {
//			for(int i=2; i<=N; i++) {
////				//deb
////				out.println("count:");
////				out.println(count);
////				out.println("ceil:");
////				out.println(((int)Math.ceil(K / i)));
////				out.println("calc:");
////				out.println(Main.calc((int)Math.ceil(K / i)));
////				out.println("min / calc:");
////				out.println(min / Main.calc((int)Math.ceil(K / i)));
////				out.flush();
////				//
//
//
//				 count += min / Main.calc((int)Math.ceil((double)K / i));
//			}
//
//			ans = (double)count/(N * min);
//		}
//
//
//
//		//************************************/
//		// ここから出力処理
//		//************************************/
//		PrintWriter out = new PrintWriter(System.out);
//
//		out.println(ans);
//
//		// 最後に必ずFlush
//		out.flush();
//	}
//
//
//	/**
//	 * xが2のべき乗かどうか調べる関数
//	 * @param x
//	 * @return 2のべき乗ならtrue。0はfalse。
//	 */
//	static boolean isPowerOfTwo(int x){
//	    return x > 0 && (x & (x - 1)) == 0;
//	}
//
//	static int calc(int num) {
//	    if(isPowerOfTwo(num)){
//	    	return num;
//	    }
//
//		int ret = 0;
//		for(int shift=2; shift<31; shift++){ // 32bit符号付整数なので30回シフト=2^31が限界
//			ret = 1 << shift;                // 1を左シフトして2のべき乗を生成
//			if(ret > num){
//				return  ret;
//			}
//		}
//		return ret;
//	}
//
//
//}

//public class Main {
//	public static void main(String[] args) {
//		FastScanner sc = new FastScanner();
//		String s = sc.next();
//
//		int sint = new Integer(s).intValue();
//		int up = sint / 100;
//		int down = sint % 100;
//
//		boolean UPMM = false;
//		if(1 <= up && up <=12) {
//			UPMM = true;
//		}
//
//		boolean DWMM = false;
//		if(1 <= down && down <=12) {
//			DWMM = true;
//		}
//
//
//
//
//
////
////		Pair[] a = { new Pair(0, 5), new Pair(1, 10), new Pair(2, 3) };
////		Arrays.sort(a, new Comparator<Pair>() {
////			public int compare(Pair o1, Pair o2) {
////				return Integer.compare(o1.v, o2.v); //Java7以降
////			}
////		});
//
//		//************************************/
//		// ここから出力処理
//		//************************************/
//		PrintWriter out = new PrintWriter(System.out);
//		if(UPMM && DWMM) {
//			out.println("AMBIGUOUS");
//		}else if(UPMM && !DWMM) {
//			out.println("MMYY");
//		}else if(!UPMM && DWMM) {
//			out.println("YYMM");
//		}else {
//			out.println("NA");
//		}
//
//
//		// 最後に必ずFlush
//		out.flush();
//	}
//}

//public class Main {
//	public static void main(String[] args) {
//		FastScanner sc = new FastScanner();
//		int N = sc.nextInt();
//		int K = sc.nextInt();
//		String S = sc.next();
//
//		PrintWriter out = new PrintWriter(System.out);
//
//		for (int i = 0; i < N; i++) {
//			char c = S.charAt(i);
//			if(i != K-1) {
//				out.print(c);
//			}else {
//				out.print(Character.toLowerCase(c));
//			}
//		}
//
//
//
////
////		Pair[] a = { new Pair(0, 5), new Pair(1, 10), new Pair(2, 3) };
////		Arrays.sort(a, new Comparator<Pair>() {
////			public int compare(Pair o1, Pair o2) {
////				return Integer.compare(o1.v, o2.v); //Java7以降
////			}
////		});
//
//		//************************************/
//		// ここから出力処理
//		//************************************/
//	//	PrintWriter out = new PrintWriter(System.out);
//
//
//		// 最後に必ずFlush
//		out.flush();
//	}
//}

///** テンプレート */
//public class Main {
//	public static void main(String[] args) {
//		FastScanner sc = new FastScanner();
//		int N = sc.nextInt();
//		int M = sc.nextInt();
//
//		int[] ary = new int[N];
//		for (int i = 0; i < N; i++) {
//			ary[i] = sc.nextInt();
//		}
////
////		Pair[] a = { new Pair(0, 5), new Pair(1, 10), new Pair(2, 3) };
////		Arrays.sort(a, new Comparator<Pair>() {
////			public int compare(Pair o1, Pair o2) {
////				return Integer.compare(o1.v, o2.v); //Java7以降
////			}
////		});
//
//		//************************************/
//		// ここから出力処理
//		//************************************/
//		PrintWriter out = new PrintWriter(System.out);
//
//		out.println("hoge");
//
//		// 最後に必ずFlush
//		out.flush();
//	}
//}

/** スキャン用 */
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	/** クラス内部用だよ */
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	/** クラス内部用だよ */
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	/**
	 * クラス内部用だよ
	 * ASCII の文字の内、表示用の文字を返す関数
	 *
	 * @return 改行とか制御文字じゃない、表示用文字ならtrue
	 * */
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	/**
	 * @return 改行文字とか空白以外を除いた、次の文字があればtrue
	 * */
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	/**
	 *
	 * @return 次の文字列
	 */
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}

		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	/**
	 *
	 * @return 次のLong
	 */
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	/**
	 *
	 * @return 次のInt
	 */
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	/**
	 *
	 * @return 次のDouble
	 */
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

class Pair {
	int k;
	int v;

	public Pair(int k, int v) {
		this.k = k;
		this.v = v;
	}
}

class PairSI {
	String k;
	int v;
	int num; // 出現順

	public PairSI(String k, int v, int num) {
		this.k = k;
		this.v = v;
		this.num = num;
	}
}

//class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {
//	/** serialVersionUID. */
//	private static final long serialVersionUID = 6411527075103472113L;
//
//	public Pair(final K key, final V value) {
//		super(key, value);
//	}
//}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    int N;
    private class Pair implements Comparable<Pair> {
        String s;
        int p;
        int index;
        public Pair(String s, int p, int index) {
            this.s = s;
            this.p = p;
            this.index = index;
        }

        public int compareTo(Pair other) {
            if (s.equals(other.s)) {
                return other.p - this.p;
            }
            return this.s.compareTo(other.s);
        }
    }
    private void solve() {
        N = nextInt();
        ArrayList<Pair> pairs = new ArrayList<>();
        for(int i = 0;i < N;i++) {
            pairs.add(new Pair(next(), nextInt(), i));
        }

        Collections.sort(pairs);

        for(Pair pair: pairs) {
            out.println(pair.index + 1);
        }
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


import java.util.*;

public class Main{

    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        Restaurant[] r = new Restaurant[n];
        for(int i = 0; i < n; i++){
            r[i] = new Restaurant(scan.next(), scan.nextInt(), i + 1);
        }
        Arrays.sort(r);
        for(int i = 0; i < n; i++) System.out.println(r[i].index);
    }

    public class Restaurant implements Comparable<Restaurant>{

        String place;
        int score;
        int index;

        public Restaurant(String place, int score, int index){
            this.place = place;v
            this.score = score;
            this.index = index;
        }

        @Override
        public int compareTo(Restaurant r) {
            if(!r.place.equals(this.place)) return this.place.compareTo(r.place);
            return Integer.compare(r.score, this.score);
        }

        @Override
        public String toString(){
            return this.place + " " + this.score + " " + this.index;
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());

		Map<String,Integer> lst = new TreeMap<String,Integer>();

		for (int i = 0; i < N; i++) {
			String s = sc.next();
			int pts = 100 - sc.nextInt();
			s = s + " " + String.valueOf(pts);
			lst.put(s,i+1);
		}

		for (String s : lst.keySet()) {
			System.out.println(lst.get(s));
		}

	}
}


import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n= sc.nextInt();
        String[] si = new String[n];
        ArrayList<String> s = new ArrayList<String>();
        int[] a = new int[n];

        for(int i=0; i<n; i++){
            si[i] = sc.next();
            s.add(si[i]);
            a[i] = sc.nextInt();
        }

        Collections.sort(s);
        int[] icount = new int[n];

        for(int i=0; i<n; i++){
            while(s.get(i)==s.get(i+1)){
                icount[i]++;
            }
            i++;
        }

        for(int i=0; i<n; i++){
            System.out.print(s.get(i));
            System.out.println(a[i]);
        }

        //System.out.println(ans);

	}
}


#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    pair<pair<string, int>, int> rest[N];
    for(int i = 0; i < N; i++){
        string S;
        int P;
        cin >> S >> P;
        rest[i] = {{S, -P}, i + 1};
    }
    sort(rest, rest + N);
    for(int i = 0; i < N; i++){
        cout << rest[i].second << endl;
    }

}


#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    Int(n);
    vector<pair<pair<string, int>, int>> data(n);
    rep(i, n) {
        cin >> data[i].ffir >> data[i].fsec;
        data[i].fsec *= -1;
        data[i].sec = i+1;
    }

    sort(all(data));

    rep(i, data.size()) {
        std::cout << data[i].sec << std::endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;

    vector<tuple<string, int, int>> rest(N);
    for (int i = 0; i < N; i++) {
        string city; int score;
        cin >> city >> score;
        rest[i] = make_tuple(city, -score, i);
    }

    sort(all(rest));

    for (auto p : rest) {
        cout << get<2>(p) + 1 << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll=long long;

int main(){
 int n;
 cin >> n;
 vector<tuple<string, int,int>> t(n);
 rep(i,n){
   string s;
   int point;
   cin >> s >> point;
   t[i]=make_tuple(s,point,i+1);
 }
 sort(t.begin(),t.end());

 rep(i,n){
   string s;
   int point;
   int a;
   tie(s,point,a)=t[i];
   cout << a << endl;
 }
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll=long long;

int main(){
 int n;
 cin >> n;
 vector<tuple<string, int,int>> t(n);
 rep(i,n){
   string s;
   int point;
   cin >> s >> point;
   t[i]=make_tuple(s,point,i+1);
 }
 sort(t.begin(),t.end());

 rep(i,n){
   string s;
   int point;
   int a;
   tie(s,point,a)=p[i];
   cout << a << endl;
 }
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll=long long;

int main(){
 int n,k=0;
 cin >> n;
 vector<tuple<string, int,int>> t(n);
 rep(i,n){
   string s;
   int point;
   cin >> s >> point;
   t[i]=make_tuple(s,point,i+1);
 }
 sort(p.begin(),p.end());

 rep(i,n){
   string s;
   int point;
   int a;
   tie(s,point,a)=p[i];
   cout << a << endl;
 }
}


#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define c_cin(X) scanf("%c",&X);
#define ll_cin(X) scanf("%lld", &X)
#define ull_cin(X) scanf("%llu", &X)
#define lf_cin(X) scanf("%lf", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  s_coutc(X) printf("%s",X)

#define  c_cout(X) printf("%c",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)

typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0

#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asorts(const void* a, const void* b);
int s_dsorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsorts(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る

//#define pai  3.1415926535
#define deg_rad(X)  (X*(M_PI/180))

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}

int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

#pragma endregion

//ABC 065 B - Trained?
//int main(void) {
//	return 0;
//
//}

//ABC 133 C - Remainder Minimization 2019

//ABC 128 B - Guidebook  100-Piして昇順にsort

static struct _s {
	char a[11];
	int   p;
	int   no;
}   s[100];

int b128_sort(const void* a, const void* b);
int b128_sort(const void* a, const void* b) {
	struct _s* pa, * pb;
	int    rc;

	rc = strcmp((char*)a, (char*)b);
	if (rc) return(rc);

	pa = (struct _s*)a; pb = (struct _s*)b;
	rc=(pa->p < pb->p)?1:-1;
	return(rc);
}

int main(void) {
	int n,i,l;

	i_cin(n);
	for (i = 0; i < n; i++) {
		s_cin(s[i].a);
		i_cin(s[i].p);

		l = strlen(s[i].a);
		s[i].a[l] = 0x00;
		s[i].no = i + 1;
	}

	qsort(s, n,sizeof(struct _s),b128_sort);
	printf("\n");
	for (i = 0; i < n; i++)
		i_cout(s[i].no);

	return 0;
}

//ABC 95-C Half and Half
//int main(void) {
//	long  a, b, c, x, y;
//	long tmp;
//	scanf("%ld %ld %ld %ld %ld", &a, &b, &c, &x, &y);
//	c *= 2;
//
//	/*if (a >= c) {
//		tmp=(long)x * c + ((y - x < 0) ? 0 :(long)(y - x) * b);
//		printf("%ld",tmp);
//		return 0;
//	}
//	if (b >= c) {
//		tmp =(long)y * c + ((x - y < 0) ? 0 : (long)(x - y) * b);
//	    printf("%ld\n", tmp);
//		return 0;
//	}*/
//
//	if ((a + b) <= c) {
//	     printf("%ld\n",a * x + b * y);
//	     return 0;
//	}
//
//	tmp = a * x + b * y;
//	if (c * _max(x, y) < tmp) {
//		printf("%ld\n",c* _max(x, y)); return 0;
//	}
//
//	tmp = c * _min(x, y);
//	tmp += ((x < y) ? (y - x) * b :(x - y) * a);
//	printf("%ld\n", tmp);
//	return 0;
//}

//066-B


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
	char s[11];
	int p;
	int no;
} data;
int cmpstr(const void *x, const void *y) {
	int res = strcmp(((data *)x)->s, ((data *)y)->s);
	if (res == 0)
		return ((data *)y)->p - ((data *)x)->p;
	else
		return res;
}
int main() {
	int n;
	data d[100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s%d", d[i].s, &d[i].p);
		d[i].no = i + 1;
	}
	qsort(d, n, sizeof(data), cmpstr);
	for (int i = 0; i < n; i++) {
		printf("%d\n", d[i].no);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
int main(void)
{
  //Nを入力
  int n;
  scanf("%d",&n);
  //市名と点数を入力
  int i,j,k,p[n],pn[n];
  char s[n][20];
  for(i=0;i<n;i++){
    scanf("%s",&s[i]);
    scanf("%d",&p[i]);
    pn[i] = i+1;
  }
  //点数順に並び替え
  int tmp;
  char stmp[20];
  for(i=0;i<n;i++)
    for(j=i+1;j<n;j++)
      if(p[i]<p[j]){
        tmp  = p[i];
        p[i] = p[j];
        p[j] = tmp;
        tmp   = pn[i];
        pn[i] = pn[j];
        pn[j] = tmp;
        strcpy(stmp,s[i]);
        strcpy(s[i],s[j]);
        strcpy(s[j],stmp);
      }
  //辞書順に並び替え
  for(i=0;i<n-1;i++){
    for(j=n-1;j>=i+1;j--)
      if(strcmp(s[j],s[j-1])<0){
        tmp  = p[j];
        p[j] = p[j-1];
        p[j-1] = tmp;
        tmp   = pn[j];
        pn[j] = pn[j-1];
        pn[j-1] = tmp;
        strcpy(stmp,s[j]);
        strcpy(s[j],s[j-1]);
        strcpy(s[j-1],stmp);
      }
//    printf("[%d] %s %d\n",pn[i], s[i], p[i]);
  }
  for (i=0; i<n; i++) {
    printf("%d\n",pn[i]);
//  printf("[%d] %s %d\n", pn[i], s[i], p[i]);
  }
  return 0;
}


#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<string, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n;
	cin >> n;
	vector<pair<P,int>>pai;
	set<string>ss;
	rep(i, n) {
		string s;
		int p;
		cin >> s >> p;
		P pp = make_pair(s, -p);
		pai.emplace_back(make_pair(pp, i));
	}
	sort(pai.begin(), pai.end());
	rep(i, n) {
		cout << pai[i].second +1<< endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> pairs;
    string s; int p;
    rep(i, N){
        cin >> s >> p;
        pairs.push_back(make_pair(make_pair(s, -p), i + 1));
    }
    sort(pairs.begin(), pairs.end());

    rep(i, N){
        cout << pairs.at(i).second << endl;
    }
}


#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define c_cin(X) scanf("%c",&X);
#define ll_cin(X) scanf("%lld", &X)
#define ull_cin(X) scanf("%llu", &X)
#define lf_cin(X) scanf("%lf", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  s_coutc(X) printf("%s",X)

#define  c_cout(X) printf("%c",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)

typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0

#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asorts(const void* a, const void* b);
int s_dsorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsorts(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る

//#define pai  3.1415926535
#define deg_rad(X)  (X*(M_PI/180))

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}

int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

#pragma endregion

//ABC 065 B - Trained?
//int main(void) {
//	return 0;
//
//}

//ABC 133 C - Remainder Minimization 2019

//ABC 128 B - Guidebook  100-Piして昇順にsort
static char s[100][20];
#define _NO 16
int main(void) {
	int n,i,l;
	int p;

	i_cin(n);
	for (i = 0; i < n; i++) {
		s_cin(s[i]);
		i_cin(p);

		l = strlen(s[i]);
		if (!p)
			s[i][l] = 'A';
		else
			sprintf(&s[i][l],   "%d",100-p);
		sprintf(&s[i][_NO], "%d", i+1);
	}

	qsort(s, n,sizeof(s[0]),s_asorts);
	printf("\n");
	for (i = 0; i < n; i++) {
		s_cout(&s[i][_NO]);
//		s_cout(s[i]);
	}

	return 0;
}

//ABC 95-C Half and Half
//int main(void) {
//	long  a, b, c, x, y;
//	long tmp;
//	scanf("%ld %ld %ld %ld %ld", &a, &b, &c, &x, &y);
//	c *= 2;
//
//	/*if (a >= c) {
//		tmp=(long)x * c + ((y - x < 0) ? 0 :(long)(y - x) * b);
//		printf("%ld",tmp);
//		return 0;
//	}
//	if (b >= c) {
//		tmp =(long)y * c + ((x - y < 0) ? 0 : (long)(x - y) * b);
//	    printf("%ld\n", tmp);
//		return 0;
//	}*/
//
//	if ((a + b) <= c) {
//	     printf("%ld\n",a * x + b * y);
//	     return 0;
//	}
//
//	tmp = a * x + b * y;
//	if (c * _max(x, y) < tmp) {
//		printf("%ld\n",c* _max(x, y)); return 0;
//	}
//
//	tmp = c * _min(x, y);
//	tmp += ((x < y) ? (y - x) * b :(x - y) * a);
//	printf("%ld\n", tmp);
//	return 0;
//}

//066-B


'use strict'

const INF = 900719925474099;

function Main(input){
    let temp = input.trim().split('\n');
    let n = parseInt(temp[0])

    let sp = [];
    let temp2;
    for(let i=1;i<=n;i++){
        temp2 = temp[i].split(' ');
        sp.push({s:temp2[0],p:parseInt(temp2[1]),num:i})
    }
    sp.sort((a,b)=>{
        if( a.s < b.s ){
            return -1;
        }else if(a.s > b.s){
            return 1;
        }else{
            return b.p - a.p;
        }
    })
    //sp.sort((a,b)=>b.p-a.p);
    //sp.sort((a,b)=>{if(a.s<b.s){return -1}else{return 1}});

    let ans = [];
    for(let i=0;i<n;i++){
        ans.push(sp[i].num);
    }
    console.log(ans.join('\n'));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const SP = arg.slice(1, N + 1);

    let list = [];

    for(let i in SP) {
        const S = SP[i].split(" ")[0];
        const P = SP[i].split(" ")[1];

        const temp = {name: S, point: P, originIdx: i};

        list.push(temp);
    }

    list.sort((a,b)=>{
        if(a.name < b.name) {
            return -1;
        }

        if(a.name > b.name) {
            return 1;
        }

        if(a.point - b.point > 0) {
            return -1;
        }

        if(a.point - b.point < 0) {
            return 1;
        }

        return 0;
    });

    // list.sort((a,b)=>a.name < b.name);
    // console.log(JSON.stringify(list));

    let answer = [];

    for(let i in list) {
        answer.push(parseInt(list[i].originIdx) + 1);
    }

    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input) {
    input = input.trim().split("\n");
    var N = parseInt(input[0],10);

    var tmp = [];
    for(var i = 0; i < N; i++){
        tmp[i] = input[i+1].split(" ")[0] + (999 - parseInt(input[i+1].split(" ")[1],10)) + "," + (i+1);
    }
    tmp.sort();

    for(var i = 0; i < N; i++){
        console.log(tmp[i].split(",")[1]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    let s = []
    let p = []
    let i = 0
    let r = {}
    while(hasNext()){
        i++
        let [s, p] = next().split(" ")
        if(!r[s]) r[s] = [[Number(p),i]]
        else r[s].push([Number(p), i])
    }
    let keys = Object.keys(r)
    keys.sort()
    let ans = ""
    for(let key of keys){
        let arr = r[key].sort((a,b) => b[0]-a[0])
        for(let el of arr) ans += String(el[1]) + "\n"
    }
}
Main()


/*
-------関数一覧--------
arr1dto2d(Array) 一次元配列を二次元配列にします
pf(N)素因数分解した結果をオブジェクトで返します
gcd(a,b)最大公約数を返します
lcm(a,b)最小公倍数を返します
num(a,b)a-bを返します。ソート用です
isPrime(n)素数かどうか真偽値で返します
isNumber(n)数かどうか真偽値で返します
arrsum(arr)配列の合計値を返します
nibu(arr,n)n以下で最も大きい数の添字を返します(nを含みます)
br(input)入力を改行で区切ります
*/
const debugMode = false;
const inf = Number.MAX_SAFE_INTEGER;

function Main(input){
    input = input.split("\n");
    var n = input[0];
    input.shift();
    input = arr1dto2d(input);
    for(var i=0;i<input.length;i++) input[i].push(i+1);
    input = input.sort(function(a,b){
    if (a[0] < b[0]) return -1;
    if (a[0] > b[0]) return 1;
    if (a[1] > b[1]) return -1;
    if (a[1] < b[1]) return 1;
    });
    input.forEach(function(val){
    console.log(val[2]);
    });
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function zisyozyunn(a){
  var arr = [];
  for(var i=0;i<input[0];i++){
    arr.push(i+1);
  }
  var sum = 0;
  for(var i=0;i<a.length;i++){
    var f = arr.findIndex(val => val==a[i]);
    sum += factorialize(a.length-1-i)*f;
    arr.splice(f,1);
  }
  return sum;
}
function arrsum(arr){
  var sum = 0;
  for (var i=0,len=arr.length; i<len; ++i) {
      sum += arr[i]-0;
  };
  return sum;
}
function debug(val){
  if(debugMode==true){
    console.log(val)
  }
}
function arrMaxPoint(arr){
	var max = Number.MIN_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(max<arr[i]){
			max = arr[i];
			point = i;
		}
	}
	return point;
}
function arrMinPoint(arr){
	var min = Number.MAX_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(min>arr[i]){
			min = arr[i];
			point = i;
		}
	}
	return point;
}
function isPrime(n){
    if(false===Number.isInteger(n)){
        return false;
    }
    if(n<=1){
        return false;
    }
    if(2===n){
        return true;
    }
    if(0===n%2){
        return false;
    }
    var square_root = Math.floor(Math.sqrt(n));
    for(var i=3; i<=square_root; i+=2){
        if(0===n%i){
            return false;
        }
    }
    return true;
}
function isNumber(val){
	const pat = /^([1-9]\d*|0)$/;
	return pat.test(val);
}
function factorialize(num) {
  if (num === 0) { return 1; }
  return num * factorialize(num-1);
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ");
    }
  return arr;
}
function rotate(array) {
  const ROW = array.length;
  const COL = array[0].length;
  const row = ROW-1;
  var a = new Array(COL);
  for (var c=0; c<COL; c++) {
    a[c] = new Array(ROW);
    for (var r=0; r<ROW; r++) {
      a[c][r] = array[row-r][c];
    }
  }
  return a;
}
function part_in(base,push,st){
	for(var i=st,p=0;p<push.length;i++,p++){
		base[i] = push[p];
	}
	return base;
}
function part_reverse(arr,s,g){
	var push = arr.slice(s-1,g);
  push.reverse();
	arr = part_in(arr,push,s-1);
	return arr;
}
function zeroPadding(num,length){
    return (num + '000000000000000000000000000000000').slice(0,length);
}
function arrsum(arr){
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += arr[i]-0;
    };
    return sum;
}
function pf(n) {
    var result = {};

    if (n === 1) {
        return {"1":1}
    }

    var init = 2;

    while (n !== 1) {
        var i = init;
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i === 0) {
                n /= i;
                if (!(result[i] > 0)) {
                    result[i] = 0;
                }
                result[i]++;
                break;
            }
            i++;
        }
        init = i;
    }
    return result;
}
function gcd(a, b) {
    if (b === 0){
        return a
    }
    return gcd(b, a % b)
}
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
}
function num(a, b) {
  return a - b;
}
function nibu(a,searchValue){
	var index = -1;

//調べる左端を表す添字(index)
var left = 0;

//調べる右端を表す添字(index)
var right = a.length-1;

//左端と右端にデータがある間は処理を繰り返す
while(left <= right){

    //左右の真ん中を表す添字(index)
    middle =Math.floor((left +right)/2);

    //真ん中の値と探す値を比較する
    if(a[middle]==searchValue){
        //一致した場合、変数に入れて処理終了
        index = middle;
        break;
    }else if(a[middle]<searchValue){
        //探す値より小さい場合、左側にはもっと小さい値しかないので左端の値を真ん中の値の右に移動する
        left = middle +1;
    }else{
        //探す値より大きい場合、右側にはもっと大きい値しかないので右端の値を真ん中の値の左に移動する
        right = middle -1;
    }
}
if(index!=-1) return index;
else return left;
}
function br(input){
  return input.split("\n");
}
function is_sortred(arr){
  var flag = true;
  for(var i=1;i<arr.length;i++){
    if(arr[i-1]>arr[i]){
      flag = false;
      break;
    }
  }
  return flag;
}
function primeFactorization(n) {

	// 平方根を保存
	var s = Math.floor(Math.sqrt(n));

	var r = 0;

	var result = {};

	// 2から平方根までの素因数を求める
	for (var i = 2;i <= s;i++) {

		if ((n % i) == 0) {

			r = 0; // 指数カウンタクリア

			do {

				r++; // 指数カウンタプラス

				n = n / i;

			} while ((n % i) == 0);

			// 素因数iを指数とともに保存
			result[i]=r;

		}

	}

	// 残った素数を追加
	if (n > s) {
		result[n] = 1;
	}

	return result;

}


'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let N = input[0].split(' ').map(Number)[0];
  // let Arr1 = input[1].split(' ').map(Number);
  let Res = [];

  // 連想配列(Dictionary)に格納
  for (let i = 1; i <= N; i++) {
    Res[i - 1] = {
      souceOrder: i,
      city: input[i].split(' ')[0],
      score: parseInt(input[i].split(' ')[1]),
      printOrder: 1
    }
  }

  // city昇順 score降順 の順に並べ替え
  Res.sort((a, b) => {
    if (a.city < b.city) return -1;
    if (a.city > b.city) return 1;
    if (a.score < b.score) return 1;
    if (a.score > b.score) return -1;
    return 0;
  });

  for (let i = 0; i < N; i++) {
    Res[i].printOrder = (i + 1);
  }
  // souceOrder昇順に並べ替え
  Res.sort((a, b) => {
    if (a.souceOrder < b.souceOrder) return -1;
    if (a.souceOrder > b.souceOrder) return 1;
    return 0;
  });

  let Ans = [];
  for (let i = 0; i < N; i++) {
    Ans.push(Res[i].printOrder);
  }

  console.log(Ans.join('\n'));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Restaurant struct {
	City  string
	Score int
	Index int
}

type Restaurants []Restaurant

func (r Restaurants) Len() int {
	return len(r)
}

func (r Restaurants) Less(i, j int) bool {
	if r[i].City != r[j].City {
		return r[i].City < r[j].City
	} else {
		return r[i].Score > r[j].Score
	}
}

func (r Restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	n := nextInt()
	r := make([]Restaurant, n)

	for i := 0; i < n; i++ {
		r[i] = Restaurant{
			next(), nextInt(), i,
		}
	}

	sort.Sort(Restaurants(r))

	for _, res := range r {
		fmt.Println(res.Index + 1)
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

type restaurant struct {
	name  string
	point int
	id    int
}

type rs []restaurant

func (r rs) Len() int {
	return len(r)
}

func (r rs) Less(i, j int) bool {
	if r[i].name == r[j].name {
		return r[i].point > r[j].point
	}
	return r[i].name < r[j].name
}

func (r rs) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	a := make(rs, n)
	for i := range a {
		a[i].id = i + 1
		fmt.Fscan(read, &a[i].name, &a[i].point)
	}

	sort.Sort(a)
	for _, r := range a {
		fmt.Fprintln(write, r.id)
	}
}


package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

type Restaurant struct {
	Index int
	City  string
	Point int
}

type Restaurants []Restaurant

func (r Restaurants) Len() int {
	return len(r)
}

func (r Restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func (r Restaurants) Less(i, j int) bool {
	return r[i].City < r[j].City
}

type ByPoint struct {
	Restaurants
}

func (b ByPoint) Less(i, j int) bool {
	return b.Restaurants[i].Point > b.Restaurants[j].Point
}

func main() {
	N := getInt()
	restaurants := Restaurants{}

	for i := 0; i < N; i++ {
		s := getString()
		p := getInt()

		restaurants = append(restaurants, Restaurant{
			Index: i + 1,
			City:  s,
			Point: p,
		})
	}

	sort.Sort(restaurants)

	var cities []string
	results := make(map[string]Restaurants)
	for _, restaurant := range restaurants {
		_, ok := results[restaurant.City]
		if !ok {
			cities = append(cities, restaurant.City)
		}
		results[restaurant.City] = append(results[restaurant.City], restaurant)
	}

	for _, city := range cities {
		restaurants := results[city]
		sort.Sort(ByPoint{restaurants})
		for _, restaurant := range restaurants {
			fmt.Println(restaurant.Index)
		}
	}
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func bfs(c int, graph *Graph) {
	next := make([]int, 0)
	next = append(next, c)
	visited := make(map[int]struct{})

	for ; len(next) != 0; {
		u := next[0]
		next = next[1:]
		visited[u] = struct{}{}

		for v := range graph.edges[u] {
			_, flag := visited[v]
			if flag {
				continue
			}

			// なにか処理

			next = append(next, v)
		}
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n%2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n%i == 0 {
			return false
		}
	}

	return true
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func makeRange(min, max int) []int {
	a := make([]int, max-min+1)
	for i := range a {
		a[i] = min + i
	}
	return a
}

func powerset2(nums []int) [][]int {
	length := int(math.Pow(2, float64(len(nums))))
	result := make([][]int, length)

	index := 0
	result[index] = []int{}
	index++

	for _, n := range nums {
		max := index
		for i := 0; i < max; i++ {
			result[index] = copyAndAppend(result[i], n)
			index++
		}
	}

	return result
}

func copyAndAppend(nums []int, n int) []int {
	dst := make([]int, len(nums)+1)
	copy(dst, nums)
	dst[len(nums)] = n
	return dst
}

func calcGcd(x, y int) int {
	if y == 0 {
		return x
	} else if x >= y {
		return calcGcd(y, x%y)
	} else {
		return calcGcd(x, y%x)
	}
}

func getDivisor(n int) []int {
	var divisor []int
	divisor = append(divisor, 1)
	if n != 1 {
		divisor = append(divisor, n)
	}

	sqrt := int(math.Sqrt(float64(n)))
	for i := 2; i <= sqrt; i++ {
		if n%i == 0 {
			divisor = append(divisor, i)
			divisor = append(divisor, n/i)
		}
	}
	return divisor
}

type intHeap []int

func (h intHeap) Len() int {
	return len(h)
}

func (h intHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h intHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func initHeap() *intHeap {
	ih := &intHeap{}
	heap.Init(ih)
	return ih
}

func (h *intHeap) pushHeap(n int) {
	heap.Push(h, n)
}

func (h *intHeap) popHeap() int {
	return heap.Pop(h).(int)
}

func factMod(n int) int {
	value := 1
	for ; n > 1; n-- {
		value = calcMod(value * n)
	}
	return value
}

func combinationMod(n, k int) int {
	factN := factMod(n)
	factK := factMod(k)
	factNK := factMod(n - k)
	factKR := powMod(factK, mod-2)
	factNKR := powMod(factNK, mod-2)
	return calcMod(factN * calcMod(factKR*factNKR))
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

type pair struct {
	rn string
	p  int
	i  int
}

func main() {
	n := nextInt()
	s := make([]pair, n)

	for i := 0; i < n; i++ {
		s[i].rn = nextStr()
		s[i].p = nextInt()
		s[i].i = i + 1
	}

	sort.Slice(s, func(i, j int) bool {
		if s[i].f == s[j].f {
			return s[i].p > s[j].p
		}
		return s[i].rn < s[j].rn
	})

	for _, v := range s {
		fmt.Println(v.i)
	}
}

func init() {
	const max = 1024
	var buf = make([]byte, max)
	sc.Buffer(buf, max)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var name string
	var n, score int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &n)

	rests := make([]string, n)
	for i, _ := range rests {
		scanner.Scan()
		fmt.Sscan(scanner.Text(), &name, &score)
		rests[i] = fmt.Sprintf("%s %d %d", name, 101-score, i+1)
	}
	sort.Strings(rests)

	tmp := make([]string, 3)
	for _, v := range rests {
		tmp = strings.Split(v, " ")
		fmt.Println(tmp[2])
	}
}


package main

import (
	"fmt"
	"sort"
	"strconv"
)

func main() {
	var n, p int
	var s string
	fmt.Scan(&n)
	keys := make([]string, n)
	rsts := make(map[string]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s, &p)
		keys[i] = s + strconv.Itoa(100-p)
		rsts[keys[i]] = i + 1
	}
	sort.Strings(keys)

	for _, k := range keys {
		fmt.Println(rsts[k])
	}
}


n = gets.to_i
sps = n.times.map { |i| [(i + 1), *gets.split] }

sps.sort_by! { |x| [x[1], -x[2].to_i] }.each do |i, _k, _v|
  puts i
end


n = gets.to_s.to_i

a = Array.new(n) do |i|
  s, point = gets.to_s.split
  e = s, -point.to_i, i+1
end

a.sort.each{|_,_,i| puts i }


n = gets.to_i
r = []
n.times do |i|
  s, p = gets.chomp.split
  r << [s, p.to_i, i + 1]
end
r.sort_by! {|s, _, _| s }
r.group_by {|s, _, _| s }.each do |_, v|
  v.sort_by! {|_, p, _| -p }
  v.each do |_, _, i|
    puts i
  end
end


n = gets.to_i
sp = []

n.times do |i|
  sp << gets.split("\s")
end

sp_dup = sp.dup

n.times do |i|
  min = [nil, nil]
  sp.each do |x|
    if !min.first || min.first > x.first
      min = x
    elsif min.first == x.first
      min = x if x.last > min.last
    end
  end
  puts sp_dup.index(sp.delete(min)) + 1
end


n = gets.to_i
sp = []
n.times do |i|
    input = gets.chomp.split
    input << i + 1
    sp << input
end
sp.sort!

orders = []
i = 0
while i < n
    count = 0

    city = sp[i][0]
    price_and_index = []
    sp.each do |arr|
        if arr.include?(city)
            count += 1
            price_and_index << [arr[1], arr[2]]
        end
    end
    price_and_index.sort!.reverse!

    order = []
    price_and_index.each do |arr|
        order << arr[1]
    end
    orders.concat(order)

    i += count
end

orders.each do |i|
    puts i
end


n=gets.to_i
a=[]
n.times{a.gets.split;a.map.with_index{|x,i|[i,x[0],x[1].to_i]}}
puts a.sort{|a,b|(a[1]<=>b[1]).nonzero?||(b[2]<=>a[2])}.map{|x|x[0]}


#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::cmp;
use std::iter::Iterator;

fn main() {
    input! {
      n: usize,
      sp:[(String, i32); n],
    }

    let mut vec = vec![];

    for (i,v) in sp.into_iter().enumerate(){
        vec.push((v.0, -v.1,i));
    }

    vec.sort();

    for elem in vec {
        println!("{}", elem.2 +1);
    }
}


use std::io;
use std::collections::HashMap;
use std::cmp;

fn procon_num_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let n:i32 = procon_num_read().pop().unwrap();
	let mut s: Vec<(String, i32)> = Vec::new();
	let mut map: HashMap<(String, i32), i32> = HashMap::new();
	for i in 0..n {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let mut iter = buf.split_whitespace();
		let a = iter.next().unwrap().to_string();
		let b = iter.next().unwrap().parse::<i32>().ok().unwrap();
		s.push((a, b));
	}
	for i in 0..n {
		map.insert(s[i as usize].clone(), i+1);
	}
	for i in 0..(n-1) {
		for j in (i+1)..n {
			let (a, b) = s[i as usize].clone();
			let (c, d) = s[j as usize].clone();
			match &a.cmp(&c) {
				cmp::Ordering::Greater => {
					s[i as usize] = (c, d);
					s[j as usize] = (a, b);
				},
				cmp::Ordering::Equal => {
					if d > b {
						s[i as usize] = (c, d);
						s[j as usize] = (a, b);
					}
				},
				_ => (),
			}
		}
	}
	for (a, b) in s {
		println!("{}", map.get(&(a, b)).unwrap());
	}
}


use std::io::*;
use std::str::FromStr;
use std::cmp::Ordering;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(Eq)]
struct Shop{
    index: usize,
    name: String,
    score: u64,
}

impl PartialEq for Shop {
    fn eq(&self, other: &Shop) -> bool {
        self.name == other.name && self.score == other.score
    }
}

impl PartialOrd for Shop {
    fn partial_cmp(&self, other: &Shop) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for Shop {
    fn cmp(&self, other: &Shop) -> Ordering{
        if self.name == other.name {
            other.score.cmp(&self.score)
        } else {
            self.name.cmp(&other.name)
        }
    }
}

fn main(){
    let n: usize = read();
    let mut s:Vec<Shop> = Vec::with_capacity(n);

    for i in 0..n {
        let e = Shop {
            index: i+1,
            name: read(),
            score: read(),
        };
        s.push(e);
    }
    s.sort();
    for e in &s{
        println!{"{}", e.index};
    }
}


macro_rules! input {
     (source = $s:expr, $($r:tt)*) => {
         let mut iter = $s.split_whitespace();
         input_inner!{iter, $($r)*}
     };
     ($($r:tt)*) => {
         let s = {
             use std::io::Read;
         let mut s = String::new();
         std::io::stdin().read_to_string(&mut s).unwrap();
         s
     };
     let mut iter = s.split_whitespace();
     input_inner!{iter, $($r)*}
     };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};
//#[proconio::fastout]
fn main() {
    input!{
        n: usize,
        sp: [(String, i32); n],
    }
    let mut btmap = BTreeMap::new();
    for (i, (s, p)) in sp.into_iter().enumerate() { btmap.entry(s).or_insert(BTreeMap::new()).insert(p, i + 1); }
    btmap.values().for_each(|rests| {
        rests.values().rev().for_each(|rest| { println!("{}", rest); })
    });
}