_n = int(raw_input())
_a = [int(x) for x in raw_input().split()]

_flg = 1
cnt = 0

while _flg:
    _flg = 0
    for i in reversed(range(1, _n)):
        if _a[i] < _a[i-1]:
            _a[i], _a[i-1] = _a[i-1], _a[i]
            cnt += 1
            _flg = 1

print(" ".join([str(x) for x in _a]))
print(cnt) _n = int(raw_input()) _n int(raw_input()) int raw_input() raw_input int(x) for x in raw_input().split() for x in raw_input().split() x raw_input().split() ().split () raw_input split for x in raw_input().split() int(x) int x _a = [int(x) for x in raw_input().split()] _a [int(x) for x in raw_input().split()] _flg = 1 _flg 1 cnt = 0 cnt 0 while _flg:
    _flg = 0
    for i in reversed(range(1, _n)):
        if _a[i] < _a[i-1]:
            _a[i], _a[i-1] = _a[i-1], _a[i]
            cnt += 1
            _flg = 1 _flg _flg = 0 _flg 0 for i in reversed(range(1, _n)):
        if _a[i] < _a[i-1]:
            _a[i], _a[i-1] = _a[i-1], _a[i]
            cnt += 1
            _flg = 1 i reversed(range(1, _n)) reversed range(1, _n) range 1 _n if _a[i] < _a[i-1]:
            _a[i], _a[i-1] = _a[i-1], _a[i]
            cnt += 1
            _flg = 1 _a[i] < _a[i-1] _a[i] _a i _a[i-1] _a i-1 i 1 _a[i], _a[i-1] = _a[i-1], _a[i] _a[i] _a i _a[i-1] _a i-1 i 1 _a[i-1] _a i-1 i 1 _a[i] _a i cnt += 1 cnt 1 _flg = 1 _flg 1 str(x) for x in _a for x in _a x _a for x in _a str(x) str x print(" ".join([str(x) for x in _a])) print " ".join([str(x) for x in _a]) " ".join " " join [str(x) for x in _a] print(cnt) print cnt _a = [int(x) for x in raw_input().split()] [int(x) for x in raw_input().split()] _a cnt = 0 0 cnt cnt += 1 1 cnt _flg = 0 0 _flg _n = int(raw_input()) int(raw_input()) _n _flg = 1 1 _flg _flg = 1 1 _flg
_n = int(raw_input())
_a = [int(x) for x in raw_input().split()]

_flg = 1
cnt = 0

while _flg:
    _flg = 0
    for i in reversed(range(1, _n)):
        if _a[i] < _a[i-1]:
            _a[i], _a[i-1] = _a[i-1], _a[i]
            cnt += 1
            _flg = 1

print(" ".join([str(x) for x in _a]))
print(cnt)