import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

 public class Main {
	private InputStream is;
	private PrintWriter out;
	int time = 0, start[], red[], black[], MOD = (int)(1e9+7), arr[];
	ArrayList<Integer>[] amp;
	boolean b[];
	Pair prr[];
	void solve() {
		int n = ni();
		int arr[] = na(n);
		PriorityQueue<Integer> pq = new PriorityQueue<>();
		for(int i : arr) pq.add(i);
		int cnt = 0, penalty = 0;
		for(int i = 11;i<=720;i++){
			int x = pq.poll();
			x--;
			if(x!=0){
				pq.add(x);
			}
			else{
				cnt++;
				penalty += Math.max(0, i-360);
			}
		}
		System.out.println(cnt+" "+penalty);
	}
	void failFn(String str, int arr[]){
		int len = 0;
		arr[0] = 0;
		int i = 1;
		while(i<arr.length){
			if(str.charAt(i)==str.charAt(len)){
				arr[i++] = ++len;
				continue;
			}
			if(len == 0){
				arr[i] = len;
				i++;
				continue;
			}
			if(str.charAt(i)!=str.charAt(len)){
				len = arr[len-1];
			}
		}
	}
	static class ST1{
		int arr[], st[], size;
		ST1(int a[]){
			arr = a.clone();
			size = 10*arr.length;
			st = new int[size];
			build(0,arr.length-1,1);
		}
		void build(int ss, int se, int si){
			if(ss==se){
				st[si] = arr[ss];
				return;
			}
			int mid = (ss+se)/2;
			int val = 2*si;
			build(ss,mid,val); build(mid+1,se,val+1);
			st[si] = Math.min(st[val], st[val+1]);
		}
		int get(int ss, int se, int l, int r, int si){
			if(l>se || r<ss || l>r) return Integer.MAX_VALUE;
			if(l<=ss && r>=se) return st[si];
			int mid = (ss+se)/2;
			int val = 2*si;
			return Math.min(get(ss,mid,l,r,val), get(mid+1,se,l,r,val+1));
		}
	}
	static class ST{
		int arr[],lazy[],n;
		ST(int a){
			n = a;
			arr = new int[10*n];
			lazy = new int[10*n];
		}
		void up(int l,int r,int val){
			update(0,n-1,0,l,r,val);
		}
		void update(int l,int r,int c,int x,int y,int val){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l>r||x>y||l>y||x>r)
				return;
			if(x<=l&&y>=r){
				lazy[c]+=val;
				return ;
			}
			int mid = l+r>>1;
			update(l,mid,2*c+1,x,y,val);
			update(mid+1,r,2*c+2,x,y,val);
			arr[c] = Math.max(arr[2*c+1], arr[2*c+2]);
		}
		int an(int ind){
			return ans(0,n-1,0,ind);
		}
		int ans(int l,int r,int c,int ind){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l==r)
				return arr[c];
			int mid = l+r>>1;
			if(mid>=ind)
				return ans(l,mid,2*c+1,ind);
			return ans(mid+1,r,2*c+2,ind);
		}
	}
	public static class FenwickTree {

	    int[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates

	    public FenwickTree(int size) {
	        array = new int[size + 1];
	    }
	    public int rsq(int ind) {
	        assert ind > 0;
	        int sum = 0;
	        while (ind > 0) {
	            sum += array[ind];
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
	            ind -= ind & (-ind);
	        }
	        return sum;
	    }
	    public int rsq(int a, int b) {
	        assert b >= a && a > 0 && b > 0;
	        return rsq(b) - rsq(a - 1);
	    }
	    public void update(int ind, int value) {
	        assert ind > 0;
	        while (ind < array.length) {
	            array[ind] += value;
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
	            ind += ind & (-ind);
	        }
	    }
	    public int size() {
	        return array.length - 1;
	    }
	}
	public static int[] shuffle(int[] a, Random gen){
		for(int i = 0, n = a.length;i < n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int d = a[i];
			a[i] = a[ind];
			a[ind] = d;
		}
	return a;
	}

	class Pair implements Comparable<Pair>{
		int u, v;
		Pair(int u, int v){
			this.u = u;
			this.v = v;
		}public int hashCode() {
			return Objects.hash();
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return ((u == other.u && v == other.v) || (v == other.u && u == other.v));
		}
		public int compareTo(Pair other) {
			//return Integer.compare(val, other.val);
			return Long.compare(u, other.u);// != 0 ? (Long.compare(u, other.u)) : (Long.compare(v,other.v));
		}
	}
	long power(long x, long y){
		long ans = 1;
		while(y>0){
			if(y%2==0){
				x = (x*x)%MOD;
				y/=2;
			}
			else{
				ans = (x*ans)%MOD;
				y--;
			}
		}
		return ans;
	}
	void soln() {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		//out.close();
		out.flush();
		//tr(System.currentTimeMillis() - s + "ms");
	}

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

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}


import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

 public class Main {
	private InputStream is;
	private PrintWriter out;
	int time = 0, start[], red[], black[], MOD = (int)(1e9+7), arr[];
	ArrayList<Integer>[] amp;
	boolean b[];
	Pair prr[];
	void solve() {
		int n = ni();
		int arr[] = na(n);
		PriorityQueue<Integer> pq = new PriorityQueue<>();
		for(int i : arr) pq.add(i);
		int cnt = 0, penalty = 0;
		for(int i = 11;i<=720 && !pq.isEmpty();i++){
			int x = pq.poll();
			x--;
			if(x!=0){
				pq.add(x);
			}
			else{
				cnt++;
				penalty += Math.max(0, i-360);
			}
		}
		System.out.println(cnt+" "+penalty);
	}
	void failFn(String str, int arr[]){
		int len = 0;
		arr[0] = 0;
		int i = 1;
		while(i<arr.length){
			if(str.charAt(i)==str.charAt(len)){
				arr[i++] = ++len;
				continue;
			}
			if(len == 0){
				arr[i] = len;
				i++;
				continue;
			}
			if(str.charAt(i)!=str.charAt(len)){
				len = arr[len-1];
			}
		}
	}
	static class ST1{
		int arr[], st[], size;
		ST1(int a[]){
			arr = a.clone();
			size = 10*arr.length;
			st = new int[size];
			build(0,arr.length-1,1);
		}
		void build(int ss, int se, int si){
			if(ss==se){
				st[si] = arr[ss];
				return;
			}
			int mid = (ss+se)/2;
			int val = 2*si;
			build(ss,mid,val); build(mid+1,se,val+1);
			st[si] = Math.min(st[val], st[val+1]);
		}
		int get(int ss, int se, int l, int r, int si){
			if(l>se || r<ss || l>r) return Integer.MAX_VALUE;
			if(l<=ss && r>=se) return st[si];
			int mid = (ss+se)/2;
			int val = 2*si;
			return Math.min(get(ss,mid,l,r,val), get(mid+1,se,l,r,val+1));
		}
	}
	static class ST{
		int arr[],lazy[],n;
		ST(int a){
			n = a;
			arr = new int[10*n];
			lazy = new int[10*n];
		}
		void up(int l,int r,int val){
			update(0,n-1,0,l,r,val);
		}
		void update(int l,int r,int c,int x,int y,int val){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l>r||x>y||l>y||x>r)
				return;
			if(x<=l&&y>=r){
				lazy[c]+=val;
				return ;
			}
			int mid = l+r>>1;
			update(l,mid,2*c+1,x,y,val);
			update(mid+1,r,2*c+2,x,y,val);
			arr[c] = Math.max(arr[2*c+1], arr[2*c+2]);
		}
		int an(int ind){
			return ans(0,n-1,0,ind);
		}
		int ans(int l,int r,int c,int ind){
			if(lazy[c]!=0){
				lazy[2*c+1]+=lazy[c];
				lazy[2*c+2]+=lazy[c];
				if(l==r)
					arr[c]+=lazy[c];
				lazy[c] = 0;
			}
			if(l==r)
				return arr[c];
			int mid = l+r>>1;
			if(mid>=ind)
				return ans(l,mid,2*c+1,ind);
			return ans(mid+1,r,2*c+2,ind);
		}
	}
	public static class FenwickTree {

	    int[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates

	    public FenwickTree(int size) {
	        array = new int[size + 1];
	    }
	    public int rsq(int ind) {
	        assert ind > 0;
	        int sum = 0;
	        while (ind > 0) {
	            sum += array[ind];
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and decrementing ind by that number
	            ind -= ind & (-ind);
	        }
	        return sum;
	    }
	    public int rsq(int a, int b) {
	        assert b >= a && a > 0 && b > 0;
	        return rsq(b) - rsq(a - 1);
	    }
	    public void update(int ind, int value) {
	        assert ind > 0;
	        while (ind < array.length) {
	            array[ind] += value;
	            //Extracting the portion up to the first significant one of the binary representation of 'ind' and incrementing ind by that number
	            ind += ind & (-ind);
	        }
	    }
	    public int size() {
	        return array.length - 1;
	    }
	}
	public static int[] shuffle(int[] a, Random gen){
		for(int i = 0, n = a.length;i < n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int d = a[i];
			a[i] = a[ind];
			a[ind] = d;
		}
	return a;
	}

	class Pair implements Comparable<Pair>{
		int u, v;
		Pair(int u, int v){
			this.u = u;
			this.v = v;
		}public int hashCode() {
			return Objects.hash();
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return ((u == other.u && v == other.v) || (v == other.u && u == other.v));
		}
		public int compareTo(Pair other) {
			//return Integer.compare(val, other.val);
			return Long.compare(u, other.u);// != 0 ? (Long.compare(u, other.u)) : (Long.compare(v,other.v));
		}
	}
	long power(long x, long y){
		long ans = 1;
		while(y>0){
			if(y%2==0){
				x = (x*x)%MOD;
				y/=2;
			}
			else{
				ans = (x*ans)%MOD;
				y--;
			}
		}
		return ans;
	}
	void soln() {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		//out.close();
		out.flush();
		//tr(System.currentTimeMillis() - s + "ms");
	}

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

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}


import java.io.*;
import java.lang.reflect.Array;
import java.security.cert.TrustAnchor;
import java.util.*;

/**
 * Created by noureldin on 2/20/17.
 */

public class main {

    public static void main(String[] args) throws Exception{
        IO io = new IO(null,null);
        int n = io.getNextInt();
        int [] A = new int[n];
        for (int i = 0;i < n;i++) A[i] = io.getNextInt();
        Arrays.sort(A);
        int sum = 10,ans = 0,cnt = 0;
        for (int i = 0;i < n;i++){
            sum += A[i];
            if(sum > 12*60) break;
            cnt ++;
            ans += Math.max(0,sum - 6*60);
        }
        io.println(cnt + " " + ans);
        io.close();
    }
}

class IO{
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter writer;
    private String inputFile,outputFile;

    public String getNext() throws FileNotFoundException, IOException{
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String getNextLine() throws FileNotFoundException, IOException{
        return br.readLine();
    }

    public int getNextInt() throws FileNotFoundException, IOException{
        return Integer.parseInt(getNext());
    }
    public long getNextLong() throws FileNotFoundException, IOException{
        return Long.parseLong(getNext());
    }

    public void print(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f" ,x);
    }
    public void println(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f\n" ,x);
    }
    public void print(Object o) throws  IOException{
        writer.print(o.toString());
    }

    public void println(Object o) throws  IOException{
        writer.println(o.toString());
    }
    public IO(String x,String y) throws FileNotFoundException, IOException{
        inputFile = x;
        outputFile = y;
        if(x != null) br = new BufferedReader(new FileReader(inputFile));
        else br = new BufferedReader(new InputStreamReader(System.in));
        if(y != null) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        else writer = new PrintWriter(new OutputStreamWriter(System.out));
    }

    protected void close() throws IOException{
        br.close();
        writer.close();
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Main1
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long 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 int i(){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 double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }

    ///////////////////////////////////////////////////////////////////////////////////////////
    //    RRRRRRRRR            AAA             HHH     HHH     IIIIIIIIIIIII   LLL           //
    //    RR    RRR           AAAAA            HHH     HHH      IIIIIIIIIII    LLL           //
    //    RR   RRR           AAAAAAA           HHH     HHH          III        LLL           //
    //    RR  RRR           AAA   AAA          HHHHHHHHHHH          III        LLL           //
    //    RRRRRR           AAA     AAA         HHHHHHHHHHH          III        LLL           //
    //    RR  RRR         AAAAAAAAAAAAA        HHH     HHH          III        LLL           //
    //    RR    RRR      AAA         AAA       HHH     HHH      IIIIIIIIIII    LLLLLLLLLLLL  //
    //    RR     RRR    AAA           AAA      HHH     HHH     IIIIIIIIIIIII   LLLLLLLLLLLL  //
    ///////////////////////////////////////////////////////////////////////////////////////////

    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int n=sc.i();
        int arr[]=sc.arr(n);
        Arrays.sort(arr);
        int sum=0;
        int i;
        for(i=0;i<n;i++)
        {
            sum+=arr[i];
            if(sum>710)
            break;
        }
        out.print(i+" ");
        int time=0;
        int penalty=0;
        for(int j=0;j<i;j++)
        {
            time+=arr[j];
            penalty+=Math.max(0,time-350);
        }
        out.println(penalty);
        out.flush();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	private void solve() throws IOException {
		int n = ni();
		int[] a = nia(n);
		Arrays.sort(a);
		int cnt = 0, penalty = 0;
		int sum = 10;
		for (int i : a) {
			sum += i;
			if (sum <= 720) {
				cnt++;
				if (sum > 360)
					penalty += (sum - 360);
			} else
				break;
		}
		out.println(cnt + " " + penalty);
		out.close();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	private int[][] na(int n) throws IOException {
		int[][] a = new int[n][2];
		for (int i = 0; i < n; i++) {
			a[i][0] = ni();
			a[i][1] = i;
		}
		return a;
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskD {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int []a = new int[n];
        for(int i=0;i<n;i++)
            a[i] = in.nextInt();

        Arrays.sort(a);
        int total = 710;
        int res = 0;
        int penalty = 0;
        int time = 0;
        for(int i=0;i<n;i++){
            time += a[i];
            if(time>710)
                break;
            res++;
            if(time>350)
                penalty+=time - 350;
        }
        out.println(res+" "+penalty);
	}
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

    }


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

/**
 * New Year Contest
 * As Gerald sets the table, Alexander sends the greeting cards, and Sergey and
 * his twins create an army of clone snowmen, Gennady writes a New Year contest.
 *
 * The New Year contest begins at 18:00 (6.00 P.M.) on December 31 and ends at
 * 6:00 (6.00 A.M.) on January 1. There are n problems for the contest. The
 * penalty time for each solved problem is set as the distance from the moment
 * of solution submission to the New Year in minutes. For example, the problem
 * submitted at 21:00 (9.00 P.M.) gets penalty time 180, as well as the problem
 * submitted at 3:00 (3.00 A.M.). The total penalty time is calculated as the
 * sum of penalty time for all solved problems. It is allowed to submit a
 * problem exactly at the end of the contest, at 6:00 (6.00 A.M.).
 *
 * Gennady opened the problems exactly at 18:00 (6.00 P.M.) and managed to
 * estimate their complexity during the first 10 minutes of the contest. He
 * believes that writing a solution for the i-th problem will take ai minutes.
 * Gennady can submit a solution for evaluation at any time after he completes
 * writing it. Probably he will have to distract from writing some solution to
 * send the solutions of other problems for evaluation. The time needed to send
 * the solutions can be neglected, i.e. this time can be considered to equal
 * zero. Gennady can simultaneously submit multiple solutions. Besides, he can
 * move at any time from writing one problem to another, and then return to the
 * first problem from the very same place, where he has left it. Thus the total
 * solution writing time of the i-th problem always equals ai minutes. Of
 * course, Gennady does not commit wrong attempts, and his solutions are always
 * correct and are accepted from the first attempt. He can begin to write the
 * solutions starting from 18:10 (6.10 P.M.).
 *
 * Help Gennady choose from the strategies that help him solve the maximum
 * possible number of problems, the one with which his total penalty time will
 * be minimum.
 *
 * Input
 * The first line contains an integer n (1 <= n <= 100) — the number of the
 * problems. The next line contains n space-separated integers ai (1 <= ai <=
 * 720) — each number shows how much time in minutes Gennady will spend writing
 * a solution to the problem.
 *
 * Output
 * Print two integers — the number of problems Gennady will solve and the total
 * penalty time considering that he chooses the optimal strategy.
 *
 * Sample test(s)
 * Input
 * 3
 * 30 330 720
 * Output
 * 2 10
 *
 * Note
 * In the sample, one of Gennady's possible optimal strategies is as follows. At
 * 18:10 (6:10 PM) he begins to write the first problem and solves it in 30
 * minutes (18:40 or 6.40 P.M.). At 18:40 (6.40 P.M.) he begins to write the
 * second problem. There are 320 minutes left before the New Year, so Gennady
 * does not have the time to finish writing the second problem before the New
 * Year. At 0:00 (12.00 A.M.) he distracts from the second problem, submits the
 * first one, and returns immediately to writing the second problem. At 0:10
 * (0.10 A.M.), he completes the solution for the second problem, submits it
 * and gets 10 minute penalty time. Note that as the total duration of the
 * contest is 720 minutes and Gennady has already spent 10 minutes on reading
 * the problems, he will not have time to solve the third problem during the
 * contest. Yes, such problems happen to exist.
 *
 * @author Europa
 */
public class NewYearContest {

    private static final int INIT_PENALTY = 10;
    private static final int MAX_PENALTY = 360;
    private static final int TOTAL_TIME = 720;

    private static int[] strategy(int[] problems) {
        Arrays.sort(problems);

        int N = 0;
        int time = INIT_PENALTY, penalty = 0;

        for (; N < problems.length && time + problems[N] <= TOTAL_TIME; N++) {
            time += problems[N];
            if (time > MAX_PENALTY) penalty += time - MAX_PENALTY;
        }

        return new int[] { N, penalty };
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        int[] problems = new int[N];
        for (int i = 0; i < N; i++) {
            problems[i] = scanner.nextInt();
        }

        int[] results = NewYearContest.strategy(problems);
        System.out.println(results[0] + " " + results[1]);
    }
}


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

public class D {
    private static final Scanner sc = new Scanner(System.in);

    void run() {
        final int n = sc.nextInt();
        int[] minute = new int[n];
        for(int i = 0; i < n; i++) {
            minute[i] = sc.nextInt();
        }
        Arrays.sort(minute);
        int res1 = 0, res2 = 0;
        for(int i = 0, t = 10; i < n; i++, res1++) {
            t += minute[i];
            if(t > 720) break;
            if(t > 360) res2 += t - 360;
        }

        System.out.println(res1 + " " + res2);
    }

    public static void main(String[] args) {
        new D().run();
    }
}


import static java.util.Arrays.deepToString;

import java.io.*;
import java.math.*;
import java.util.*;

public class D {

	static int[] solve(int [] a) {
		Arrays.sort(a);
		for (int i = 0, time = 10, cost = 0; i <= a.length; time += a[i], i++) {
			if (i == a.length || a[i] + time > 720) {
				return new int[] {i, cost};
			}
			cost += a[i] + time <= 360 ? 0 : a[i] + time - 360;
		}
		return null;
	}

	public static void main(String[] args) throws Exception {
		reader = new BufferedReader(new InputStreamReader(System.in));
		writer = new PrintWriter(System.out);

		setTime();
		int n = nextInt();
		int [] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		int [] res = solve(a);
		writer.println(res[0] + " " + res[1]);
		printTime();
		printMemory();

		writer.close();
	}

	static BufferedReader reader;
	static PrintWriter writer;
	static StringTokenizer tok = new StringTokenizer("");
	static long systemTime;

	static void debug(Object... o) {
		System.err.println(deepToString(o));
	}

	static void setTime() {
		systemTime = System.currentTimeMillis();
	}

	static void printTime() {
		System.err.println("Time consumed: " + (System.currentTimeMillis() - systemTime));
	}

	static void printMemory() {
		System.err.println("Memory consumed: "
				+ (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000 + "kb");
	}

	static String next() {
		while (!tok.hasMoreTokens()) {
			String w = null;
			try {
				w = reader.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (w == null)
				return null;
			tok = new StringTokenizer(w);
		}
		return tok.nextToken();
	}

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

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

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

	static BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
}


import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

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

class TaskD {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n=in.nextInt();
        int a[]=new int[n];
        int i;
        for(i=0;i<n;i++)
            a[i]=in.nextInt();
        Arrays.sort(a);
        int sum=10;
        int b[]=new int[n];
        for(i=0;i<n;i++)
        {
            sum+=a[i];
            b[i]=sum;
        }
        int c=0,p=0;
        for(i=0;i<n;i++)
        {
            if(b[i]<=720)
                c++;
            if(b[i]>300&&b[i]<=720)
                p+=b[i]-360;
        }
        out.println(c+" "+p);
	}
}


import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

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

class TaskD {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n=in.nextInt();
        int a[]=new int[n];
        int i;
        for(i=0;i<n;i++)
            a[i]=in.nextInt();
        Arrays.sort(a);
        int sum=10;
        int b[]=new int[n];
        for(i=0;i<n;i++)
        {
            sum+=a[i];
            b[i]=sum;
        }
        int c=0,p=0;
        for(i=0;i<n;i++)
        {
            if(b[i]<=720)
                c++;
            if(b[i]>360&&b[i]<=720)
                p+=b[i]-360;
        }
        out.println(c+" "+p);
	}
}


import java.io.*;
import java.util.*;

public class D {

	public D () throws IOException {
		int N = sc.nextInt();
		int [] P = new int [N];
		for (int i = 0; i < N; ++i)
			P[i] = sc.nextInt();
		solve(N, P);
	}

	public void solve (int N, int [] P) {
		t = millis();
		Arrays.sort(P);
		int T = 10, C = 0, X = 0;
		for (int p : P) {
			T += p;
			if (T <= 720) {
				++C;
				if (T > 360)
					X += T - 360;
			}
		}
		print (C + " " + X);
	}

	////////////////////////////////////////////////////////////////////////////////////

	static Scanner sc;
	static long t;

	static void print2 (Object o) {
		System.out.println(o);
	}

	static void print (Object o) {
		print2(o);
		//print2((millis() - t) / 1000.0);
		System.exit(0);
	}

	static void run () throws IOException {
		sc = new Scanner(System.in);
		new D();
	}

	public static void main(String[] args) throws IOException {
		run();
	}

	static long millis() {
		return System.currentTimeMillis();
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class C100P4 {

    private static BufferedReader in;
    private static PrintWriter out;
    private static StringTokenizer input;

    public static void main(String[] args) throws IOException {
        //-------------------------------------------------------------------------
        //Initializing...
        new C100P4();
        //-------------------------------------------------------------------------
        //put your code here... :)
        int n = nextInt();
        int[]p = new int[n];
        for (int i = 0; i < p.length; i++) {
            p[i]=nextInt();
        }
        Arrays.sort(p);
        int left=710;
        int c = 360;
        int s=0;
        int ss=0;
        for (int i = 0; i < p.length; i++) {
            if(p[i]>left)break;
            left-=p[i];
            if(left<c)ss+=(c-left);
            s++;
        }
        writeln(s+" "+ss);
        //-------------------------------------------------------------------------
        //closing up
        end();
        //--------------------------------------------------------------------------

    }
    public C100P4() throws IOException {
        //Input Output for Console to be used for trying the test samples of the problem
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        //-------------------------------------------------------------------------
        //Initalize Stringtokenizer input
        input = new StringTokenizer(in.readLine());
    }

    private static int nextInt() throws IOException {
        if (!input.hasMoreTokens())input=new StringTokenizer(in.readLine());
        return Integer.parseInt(input.nextToken());
    }
    private static long nextLong() throws IOException {
        if (!input.hasMoreTokens())input=new StringTokenizer(in.readLine());
        return Long.parseLong(input.nextToken());
    }
    private static double nextDouble() throws IOException {
        if (!input.hasMoreTokens())input=new StringTokenizer(in.readLine());
        return Double.parseDouble(input.nextToken());
    }
    private static String nextString() throws IOException {
        if (!input.hasMoreTokens())input=new StringTokenizer(in.readLine());
        return input.nextToken();
    }
    private static void write(String output){
        out.write(output);
        out.flush();
    }
    private static void writeln(String output){
        out.write(output+"\n");
        out.flush();
    }
    private static void end() throws IOException{
        in.close();
        out.close();
        System.exit(0);
    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class cf100d {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line;

		int n = 0;
		try {
			if ((line = br.readLine()) != null) {
				n = Integer.parseInt(line);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		int[] times = new int[n];
		try {
			if ((line = br.readLine()) != null) {
				String[] sp = line.split(" ");
				int i = 0;
				for (String s : sp) {
					int p = Integer.parseInt(s);
					times[i] = p;
					i++;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		Arrays.sort(times);
		int solved = 0;
		int past = 10;
		int penalty = 0;
		for (int time : times) {
			if (past + time <= 360) {
				solved++;
				past += time;
			} else if (past + time <= 720) {
				solved++;
				past += time;
				penalty += past - 360;
			} else {
				break;
			}
		}
		System.out.println(solved + " " + penalty);
	}
}


import java.io.*;
import java.util.*;

public class D implements Runnable {
    private MyScanner in;
    private PrintWriter out;

    private void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int can = 0;
        int sum = 0;
        int time = 710;
        for (int i = 0; i < n; ++i) {
            if (sum + a[i] > time) {
                break;
            }
            sum += a[i];
            ++can;
        }
        int ctime = -350;
        int pay = 0;
        for (int i = 0; i < can; ++i) {
            ctime += a[i];
            if (ctime > 0) {
                pay += ctime;
            }
        }
        out.println(can + " " + pay);
    }

    @Override
    public void run() {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    public static void main(String[] args) {
        new D().run();
    }

    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        private String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            try {
                st = null;
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

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

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

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

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


import java.util.*;
public class cf140d {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int[] v = new int[n];
    for(int i=0; i<n ;i++) v[i] = in.nextInt();
    Arrays.sort(v);
    int timeA = 350, timeB = 360;
    int solve = 0, pen = 0;
    for(int x : v) {
      if(x > timeA + timeB) continue;
      int d = Math.min(x,timeA);
      x -= d;
      timeA -= d;
      solve++;
      timeB -= x;
      if(timeA == 0) pen += 360-timeB;
    }
    System.out.println(solve + " "+ pen);
  }
}


import java.util.*;
public class cf140d {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int[] v = new int[n];
    for(int i=0; i<n ;i++) v[i] = in.nextInt();
    Arrays.sort(v);
    int timeA = 350, timeB = 360;
    int solve = 0, pen = 0;
    for(int x : v) {
      if(x > timeA + timeB) continue;
      int d = Math.min(x,timeA);
      x -= d;
      timeA -= d;
      solve++;
      pen += x;
      timeB -= x;
    }
    System.out.println(solve + " "+ pen);
  }
}


import java.io.*;
import java.util.*;
public class D {
	final public void solve() throws IOException {
		int n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		Arrays.sort(a);
		int sum = -360 + 10;
		int ans = 0;
		int pen = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i];
			if (sum > 360) break;
			ans++;
			if (sum > 0)
				pen += sum;
		}
		System.out.println(ans + " " + pen);
	}

	public static void main(String[] args) throws FileNotFoundException {
		new D().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	final public void run() {
		try {
			long tbegin = System.currentTimeMillis();
			reader = new BufferedReader(new InputStreamReader(System.in));
			//reader = new BufferedReader(new InputStreamReader(new FileInputStream("fselect.inp")));
			tokenizer = null;
			writer = new PrintWriter(new OutputStreamWriter(System.out));
			//writer = new PrintWriter(new FileOutputStream("fselect.out"));
			solve();
			//reader.close();
			//System.out.println(System.currentTimeMillis() - tbegin + "ms...");
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	final int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	final long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	final double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	final String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


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

public class D {

    void run(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        Arrays.sort(a);
        int s = 0, p = 0, t = -350;
        while(t<=360&&s<n){
            t += a[s];
            if(360<t)break;
            s++;
            if(t<=0)continue;
            p+=t;
        }
        System.out.println(s+" "+p);
    }

    public static void main(String[] args) {
        new D().run();
    }
}


import java.io.*;
import java.util.*;

public class D {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

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

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

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

    void solve() throws Exception {
        int n = nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        Arrays.sort(a);
        int sd = 0;
        int rt = 710;
        int pen = 0;
        for (int i = 0; i < n; i++) {
            if (rt >= a[i]) {
                if (rt - a[i] <= 360)
                    pen += 360 - rt + a[i];
                sd++;
                rt -= a[i];
            }
        }
        out.println(sd + " " + pen);
    }

    void run() {
        try {
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader((System.in)));
            out = new PrintWriter(System.out);

            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public static void main(String[] args) {
        new D().run();

    }

}


import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
public class D {
	public static void main(String[] args) throws IOException	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int[] list = new int[n];
		for(int i = 0; i < n; i++)	{
			list[i] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(list);
		int start = -350;
		int pen = 0;
		int ret = 0;
		for(int out: list)	{
			if(start + out <= 360)	{
				start += out;
				ret++;
				pen += Math.max(0, start);
			}
		}
		System.out.println(ret + " " + pen);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.*;
import java.util.*;

public class D {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
		String s=r.readLine();
		int n=new Integer(s);
		int[] arr=new int[n];
		s=r.readLine();
		String[] sp=s.split("[ ]+");
		for (int i = 0; i < sp.length; i++) {
			arr[i]=new Integer(sp[i]);
		}
		Arrays.sort(arr);
		int acc=0;
		int tot=0;
		for (int i = 0; i < sp.length; i++) {
			if(acc+arr[i]>710){
				break;
			}
			acc+=arr[i];
			tot++;
		}
		System.out.print(tot+" "+(acc-350));

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.*;
import java.util.*;

public class D {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
		String s=r.readLine();
		int n=new Integer(s);
		int[] arr=new int[n];
		s=r.readLine();
		String[] sp=s.split("[ ]+");
		for (int i = 0; i < sp.length; i++) {
			arr[i]=new Integer(sp[i]);
		}
		Arrays.sort(arr);
		int acc=0;
		int tot=0;
		for (int i = 0; i < sp.length; i++) {
			if(acc+arr[i]>710){
				break;
			}
			acc+=arr[i];
			tot++;
		}
		int curr = 10;
		int res=0;
		for(int i=0;i<tot;i++){
			curr+=arr[i];
			if(curr>360){
				res+=curr-360;
			}
		}
		System.out.println(tot+" "+res);

	}

}


import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] times = new int[n];
		for(int i = 0; i < n; i++) {
			times[i] = sc.nextInt();
		}
		Arrays.sort(times);
		int tleft = 710;
		int solved = 0;
		int penalty = 0;
		for(int i = 0; i < n; i++) {
			if(tleft > times[i]) {
				solved++;
				tleft -= times[i];
				if(tleft < 360) {
					penalty += 360 - tleft;
				}
			}
		}
		System.out.print(solved + " " + penalty);
	}
}


import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] times = new int[n];
		for(int i = 0; i < n; i++) {
			times[i] = sc.nextInt();
		}
		Arrays.sort(times);
		int tleft = 710;
		int solved = 0;
		int penalty = 0;
		for(int i = 0; i < n; i++) {
			if(tleft >= times[i]) {
				solved++;
				tleft -= times[i];
				if(tleft < 360) {
					penalty += 360 - tleft;
				}
			}
		}
		System.out.print(solved + " " + penalty);
	}
}


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

public class D {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[]a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int cur_time = 10;
		int cnt = 0, penaltime = 0;
		for (int i = 0; i < n; i++) {
			if (cur_time+a[i] <= 360) {
				cur_time += a[i];
				cnt++;
			}
			else {
				if (cur_time+a[i] <= 720) {
					cur_time += a[i];
					penaltime = cur_time-360;
					cnt++;
					for (int j = i+1; j < n; j++) {
						if (cur_time+a[j] <= 720) {
							cnt++;
							cur_time += a[j];
							penaltime += cur_time-360;
						}
					}
				}
				break;
			}
		}
		System.out.println(cnt+" "+penaltime);
	}
}


import java.io.*;
import java.math.*;
import java.util.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	int n;
	int a[];

	public void solve() throws Exception {
		n = nextInt();
		a = new int [n];
		for (int i = 0 ; i < n ; i++)
			a[i] = nextInt();

		Arrays.sort(a);

		int sum = 0;
		int count = 0;
		for (int i = 0; i < n; i++)
			if (sum + a[i] <= 350) {
				sum += a[i];
				count++;
			}

		int bestBeforeNY = count;

		int bestAnswer1 = -1;

		int dp [][] = new int [bestBeforeNY+1][351];

		for (int i = 0; i <= bestBeforeNY; i++)
			Arrays.fill(dp[i], -1);

		dp[0][0] = 0;

		for (int i = 1; i <= bestBeforeNY; i++) {
			for (int time = 0; time <= 350; time++) {
				for (int j = 1 ; j <= n; j++)
					if (time - a[j-1] >= 0 && dp[i-1][time - a[j-1]] != -1 && j > dp[i-1][time - a[j-1]]) {
						dp[i][time] = j;
						break;
					}
			}
		}

		int besttasks = -1;
		int bestpenalty = 1000000000;

		for (int ttime = 350; ttime >= 0; ttime--) {
			int curtime = 0;
			int tasks = 0;
			int penalty = 0;
			boolean used [] = new boolean [n];
			int time = ttime;
			if (dp[bestBeforeNY][time] != -1) {
				int previ = n + 1;
				int lvl = bestBeforeNY;
				while (lvl > 0) {
					int maxi = dp[lvl][time];
					for (int i = dp[lvl][time] + 1; i < previ && time - a[i - 1] >= 0; i++) {
						if (dp[lvl - 1][time - a[i-1] ] != -1 && dp[lvl - 1][time - a[i-1]] < previ) {
							maxi = i;
						}
					}
					used [maxi - 1] = true;
					time -= a[maxi - 1];
					previ = maxi;
					curtime += a[maxi - 1];
					tasks++;
					lvl--;
				}
				for (int i = 0; i < n; i++)
					if (!used[i]) {
						if (curtime + a[i] <= 710) {
							curtime += a[i];
							penalty += (curtime - 350);
							tasks++;
						}
					}
				if (tasks > besttasks || (tasks == besttasks && penalty < bestpenalty)) {
					besttasks = tasks;
					bestpenalty = penalty;
				}
			}
		}

		out.println(besttasks+" "+bestpenalty);

	}

	/********************************************************************************************/
	/* THERE IS INPUT */

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	long stime=0;

	private String next() throws Exception {
		while (st == null || !st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	private int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	private long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	private double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	public void run() {
		try {
			//Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			//in = new BufferedReader(new FileReader(fname+".in"));
			//out = new PrintWriter(new FileWriter(fname+".out"));
			solve();
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Exception {
		new Thread(null, new Solution(), "", 1 << 25).start();
	}

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {

    StreamTokenizer st;
    BufferedReader in;
    PrintWriter out;
//  int n;

    public static void main(String[] args) throws IOException {
        new Main().run();

    }

    String nextString() throws IOException{
        st.nextToken();
        return st.sval;
    }

    int nextInt() throws IOException{
        st.nextToken();
        return (int)st.nval;
    }

    long nextLong() throws IOException{
        st.nextToken();
        return (long)st.nval;
    }

    double nextDouble() throws IOException{
        st.nextToken();
        return (double)st.nval;
    }

    void run() throws IOException {
//      in = new BufferedReader(new FileReader("input.txt"));
        in = new BufferedReader(new InputStreamReader(System.in));
        st = new StreamTokenizer(in);
//      out = new PrintWriter(new FileWriter("output.txt"));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        out.flush();
    }

//  int max(int r1, int r2){
//      if (r2 > r1){
//          return 0;
//      }
//      if (2 * r2 > r1){
//          return 1;
//      }
//      if (2 * r2 == r1){
//          return 2;
//      }
//      double t = (double)r2 / (double)(r1 - r2);
//      if (t <= Math.sin(Math.PI / n)){
//          return n;
//      } else {
//          return n - 1;
//      }
////        double a = Math.asin(t);
////        double q = Math.PI / 5;
////        double w = Math.tan(q);
////        return (int) (Math.floor(Math.PI / a));
//  }

    void solve() throws IOException{
//      n = nextInt();
//      int R = nextInt();
//      int r = nextInt();
//      if (n<=max(R, r)){
//          out.print("YES");
//      } else {
//          out.print("NO");
//      }
//      int n= nextInt();
//      int[] mas = new int[n];
//      for (int i=0; i<n; i++){
//          mas[i] = nextInt();
//      }
//      for (int i=0; i<n; i++){
//          for (int j=i+1; j<n; j++){
//              int k1 = 0;
//              int k2 = 0;
//              for (int k=0; k<n; k++){
//                  if (mas[k]==mas[i]){
//                      k1++;
//                  }
//                  if (mas[k]==mas[j]){
//                      k2++;
//                  }
//              }
//              if (k1 < k2 || (k1==k2 && mas[i]>mas[j])){
//                  int temp = mas[i];
//                  mas[i] = mas[j];
//                  mas[j] = temp;
//              }
//          }
//      }
////        Arrays.sort(mas);
//      int otv = 0;
//      int x = 0;
//      int y = 1;
//      int z = 2;
//      int[][] res = new int[n][3];
//      boolean used[] = new boolean[n];
//      while (x <= n - 3){
//          y = Math.max(x + 1,y);
//          while(y<n && (mas[y]==mas[x] || used[y])){
//              y++;
//          }
//          if (y>n-2){
//              break;
//          }
//          z = Math.max(z, y + 1);
//          while (z < n && (mas[z]==mas[y] || used[z])){
//              z++;
//          }
//          if (z>n-1){
//              break;
//          }
//          if (!used[x] && !used[y] && !used[z] && mas[x]!=mas[y] && mas[y]!=mas[z]){
//              res[otv][0] = mas[x];
//              res[otv][1] = mas[y];
//              res[otv][2] = mas[z];
//              Arrays.sort(res[otv]);
//              used[x] = true;
//              used[y] = true;
//              used[z] = true;
//              otv++;
//              while (x<n && used[x]){
//                  x++;
//              }
//          }
//      }
//      out.println(otv);
//      for (int i=0; i<otv; i++){
//          out.println(res[i][2] + " " + res[i][1] + " " + res[i][0]);
//      }
//      int n = nextInt();
//      int[][] f = new int[n][n];
//      int[] m = new int[n];
//      int[] mi = new int[n];
//      int res[][] = new int[n][3];
//      for (int i=0; i<n; i++){
//          res[i][1] = -1;
//      }
//      for (int i=0; i<n; i++){
//          for (int j=0; j<n; j++){
//              int x = nextInt();
//              f[i][x - 1] = j;
//          }
//      }
//      for (int i=0; i<n; i++){
//          mi[i] = nextInt();
//          m[mi[i] - 1] = i;
//      }
//      for (int i=1; i<n; i++){
//          res[i][0] = 1;
//          res[i][1] = f[i][0];
//          res[i][2] = 1;
//      }
//      res[0][0] = -1;
//      res[0][1] = n + 4;
//      res[0][2] = -1;
//      int favo = 1;
//      int prfavo = -1;
//      int fav = m[0];
//      int prfav = n + 1;
//      for (int i=2; i<=n; i++){
//          if (m[i - 1] < fav){
//              prfavo = favo;
//              favo = i;
//              prfav = fav;
//              fav = m[i - 1];
//          } else {
//              if (m[i - 1] < prfav){
//                  prfav = m[i - 1];
//                  prfavo = i;
//              }
//          }
//          for (int j=0; j<n; j++){
//              if (favo != j+1 && f[j][favo - 1]<res[j][1]){
//                  res[j][0] = favo;
//                  res[j][1] = f[j][favo - 1];
//                  res[j][2] = i;
//              }
//              if (favo == j+1 &&f[j][prfavo - 1]<res[j][1]){
//                  res[j][0] = prfavo;
//                  res[j][1] = f[j][prfavo - 1];
//                  res[j][2] = i;
//              }
//          }
//      }
//      for (int i=0; i<n; i++){
//          out.print(res[i][2] + " ");
//      }
        int n = nextInt();
        int[] mas = new int[n];
        for (int i=0; i<n; i++){
            mas[i] = nextInt();
        }
        Arrays.sort(mas);
        int count = 0;
        int pen = 0;
        int time = 10;
        for (int i=0; i<n; i++){
            if (time + mas[i]<=720){
                time = time + mas[i];
                count++;
                pen = pen + Math.max(0, time - 360);
            }
        }
        out.print(count + " " + pen);
    }

}


import java.io.* ;
import java.util.*;

import static java.lang.Math.* ;
import static java.util.Arrays.* ;

public class D {

	public static void main(String[] args) throws IOException {

		new D().solveProblem();

		out.close();
	}

	static Scanner in = new Scanner(new InputStreamReader(System.in));
	//static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	static PrintStream out = new PrintStream(new BufferedOutputStream(System.out));

	public void solveProblem() {

		int n = in.nextInt() ;
		int[] get = readGet(n) ;
		sort(get) ;

		int pt = 0 ;
		int som = 10 ;
		int opl = 0 ;
		for( int i = 0 ; i < n ; i++ ){
			som += get[i] ;
			if( som > 720 )
				break ;
			opl++ ;

			if( som > 360 )
				pt += som - 360 ;
		}

		out.println(opl + " " + pt) ;
	}

	static int[] readGet( int n ){
	  	int[] get = new int[n] ;
	  	for( int i = 0 ; i < n ; i++ )
	  		get[i] = in.nextInt();
	  	return get ;
	}

}


import java.io.*;
import java.util.*;

public class NewYearContest {

	static int n;
	static int[] a;

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(in.readLine());
		a = new int[n];
		StringTokenizer st = new StringTokenizer(in.readLine());
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(a);
		int prob = 0;
		int pen = 0;
		int t = -350;
		for (int i = 0; i < n; i++) {
			int c = a[i];
			t += c;
			if (t <= 360) {
				prob++;
				pen += Math.max(0, t);
			}
		}
		System.out.println(prob + " " + pen);
	}
}


import java.awt.Polygon;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class D implements Runnable {

    private void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = nextInt();
        }
        boolean[][] rich = new boolean[n + 1][711];
        int[][] score = new int[n + 1][711];
        rich[0][0] = true;
        int scr = 0;
        for (int i = 0; i < n; ++i) {
            for (int s = 0; s < 711; ++s) {
                scr = Math.max(s + a[i] - 350, 0);
                for (int tsk = 0; tsk <= i; ++tsk) {
                    if (rich[tsk][s] && s + a[i] <= 710) {
                        //System.out.println(scr);
                        if ((!rich[tsk + 1][s + a[i]] || (rich[tsk + 1][s + a[i]]
                         && score[tsk + 1][s + a[i]] > score[tsk][s] + scr))) {
                            score[tsk + 1][s + a[i]] = score[tsk][s] + scr;
                            rich[tsk + 1][s + a[i]] = true;
                        }
                    }
                }
            }
        }

        int min = Integer.MAX_VALUE;
        for (int tsk = n; tsk >= 0; --tsk) {
            for (int s = 0; s <= 710; ++s) {
                if (rich[tsk][s]) {
                    min = Math.min(score[tsk][s], min);
                }
            }
            if (min != Integer.MAX_VALUE) {
                out.println(tsk + " " + min);
                return;
            }
        }

    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        (new Thread(new D())).start();
    }

    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter out;
    private String filename = "";

    @Override
    public void run() {
        try {
            br  = new BufferedReader(new InputStreamReader(System.in));
            st  = new StringTokenizer("");
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            String temp = br.readLine();
            if (temp == null) {
                return null;
            }
            st = new StringTokenizer(temp);
        }
        return st.nextToken();
    }
    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}


import java.awt.Polygon;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class D implements Runnable {

    private void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = nextInt();
        }
        Arrays.sort(a);
        boolean[][] rich = new boolean[n + 1][711];
        int[][] score = new int[n + 1][711];
        rich[0][0] = true;
        int scr = 0;
        for (int i = 0; i < n; ++i) {
            for (int s = 0; s < 711; ++s) {
                scr = Math.max(s + a[i] - 350, 0);
                for (int tsk = 0; tsk <= i; ++tsk) {
                    if (rich[tsk][s] && s + a[i] <= 710) {
                        //System.out.println(scr);
                        if ((!rich[tsk + 1][s + a[i]] || (rich[tsk + 1][s + a[i]]
                         && score[tsk + 1][s + a[i]] > score[tsk][s] + scr))) {
                            score[tsk + 1][s + a[i]] = score[tsk][s] + scr;
                            rich[tsk + 1][s + a[i]] = true;
                        }
                    }
                }
            }
        }

        int min = Integer.MAX_VALUE;
        for (int tsk = n; tsk >= 0; --tsk) {
            for (int s = 0; s <= 710; ++s) {
                if (rich[tsk][s]) {
                    min = Math.min(score[tsk][s], min);
                }
            }
            if (min != Integer.MAX_VALUE) {
                out.println(tsk + " " + min);
                return;
            }
        }

    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        (new Thread(new D())).start();
    }

    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter out;
    private String filename = "";

    @Override
    public void run() {
        try {
            br  = new BufferedReader(new InputStreamReader(System.in));
            st  = new StringTokenizer("");
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            String temp = br.readLine();
            if (temp == null) {
                return null;
            }
            st = new StringTokenizer(temp);
        }
        return st.nextToken();
    }
    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}


import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.util.*;

public class D{

    void solve()throws Exception
    {

        int n=nextInt();
        int[]a=new int[n];
        for(int i=0;i<n;i++)
            a[i]=nextInt();
        Arrays.sort(a);
        int low=0;
        int high=n+1;
        int ans=Integer.MAX_VALUE;
        while (high-low>1)
        {
            int mid=(low+high)/2;
            int t=get(mid,a);
            if(t!=Integer.MAX_VALUE)
            {
                low=mid;
                ans=t;
            }
            else
                high=mid;

        }
        System.out.println(low+" "+ans);

    }

    private int get(int p, int[] a) {
        int res=0;
        int time=10;
        int half=6*60;
        int tot=12*60;
        for(int i=0;i<p;i++)
        {
            time+=a[i];
            if(time<=half)
                ;
            else
            {
                if(time>tot)
                    return Integer.MAX_VALUE;
                res+=time-half;
            }
        }

        return res;
    }

    ////////////
    BufferedReader reader;
    PrintWriter writer;
    StringTokenizer stk;
    void run()throws Exception
    {
        reader=new BufferedReader(new InputStreamReader(System.in));
        stk=null;
        writer=new PrintWriter(System.out);
        solve();
        reader.close();
        writer.close();
    }
    int nextInt()throws Exception
    {
        return Integer.parseInt(nextToken());
    }

    long nextLong()throws Exception
    {
        return Long.parseLong(nextToken());

    }
    double nextDouble()throws Exception
    {
        return Double.parseDouble(nextToken());

    }

    String nextString()throws Exception
    {
        return nextToken();
    }
    String nextLine()throws Exception
    {
        return reader.readLine();
    }
    String nextToken()throws Exception
    {
        if(stk==null || !stk.hasMoreTokens())
        {
            stk=new StringTokenizer(nextLine());
            return nextToken();

        }
        return stk.nextToken();
    }

    public static void main(String[]args) throws Exception
    {
        new D().run();
    }

}


import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.util.*;

public class D{

    void solve()throws Exception
    {

        int n=nextInt();
        int[]a=new int[n];
        for(int i=0;i<n;i++)
            a[i]=nextInt();
        Arrays.sort(a);
        int low=0;
        int high=n+1;
        int ans=0;
        while (high-low>1)
        {
            int mid=(low+high)/2;
            int t=get(mid,a);
            if(t!=Integer.MAX_VALUE)
            {
                low=mid;
                ans=t;
            }
            else
                high=mid;

        }
        System.out.println(low+" "+ans);

    }

    private int get(int p, int[] a) {
        int res=0;
        int time=10;
        int half=6*60;
        int tot=12*60;
        for(int i=0;i<p;i++)
        {
            time+=a[i];
            if(time<=half)
                ;
            else
            {
                if(time>tot)
                    return Integer.MAX_VALUE;
                res+=time-half;
            }
        }

        return res;
    }

    ////////////
    BufferedReader reader;
    PrintWriter writer;
    StringTokenizer stk;
    void run()throws Exception
    {
        reader=new BufferedReader(new InputStreamReader(System.in));
        stk=null;
        writer=new PrintWriter(System.out);
        solve();
        reader.close();
        writer.close();
    }
    int nextInt()throws Exception
    {
        return Integer.parseInt(nextToken());
    }

    long nextLong()throws Exception
    {
        return Long.parseLong(nextToken());

    }
    double nextDouble()throws Exception
    {
        return Double.parseDouble(nextToken());

    }

    String nextString()throws Exception
    {
        return nextToken();
    }
    String nextLine()throws Exception
    {
        return reader.readLine();
    }
    String nextToken()throws Exception
    {
        if(stk==null || !stk.hasMoreTokens())
        {
            stk=new StringTokenizer(nextLine());
            return nextToken();

        }
        return stk.nextToken();
    }

    public static void main(String[]args) throws Exception
    {
        new D().run();
    }

}


import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.util.*;

public class D{

    void solve()throws Exception
    {

        int n=nextInt();
        int[]a=new int[n];
        for(int i=0;i<n;i++)
            a[i]=nextInt();
        Arrays.sort(a);
        int low=0;
        int high=n+1;
        int ans=Integer.MAX_VALUE;
        while (high-low>1)
        {
            int mid=(low+high)/2;
            int t=get(mid,a);
            if(t!=Integer.MAX_VALUE)
            {
                low=mid;
                ans=t;
            }
            else
                high=mid;

        }
        System.out.println(low+" "+ans);

    }

    private int get(int p, int[] a) {
        int res=0;
        int time=10;
        int half=6*60-10;
        int tot=12*60-10;
        for(int i=0;i<p;i++)
        {
            time+=a[i];
            if(time<=half)
                ;
            else
            {
                if(time>tot)
                    return Integer.MAX_VALUE;
                res+=time-(half+10);
            }
        }

        return res;
    }

    ////////////
    BufferedReader reader;
    PrintWriter writer;
    StringTokenizer stk;
    void run()throws Exception
    {
        reader=new BufferedReader(new InputStreamReader(System.in));
        stk=null;
        writer=new PrintWriter(System.out);
        solve();
        reader.close();
        writer.close();
    }
    int nextInt()throws Exception
    {
        return Integer.parseInt(nextToken());
    }

    long nextLong()throws Exception
    {
        return Long.parseLong(nextToken());

    }
    double nextDouble()throws Exception
    {
        return Double.parseDouble(nextToken());

    }

    String nextString()throws Exception
    {
        return nextToken();
    }
    String nextLine()throws Exception
    {
        return reader.readLine();
    }
    String nextToken()throws Exception
    {
        if(stk==null || !stk.hasMoreTokens())
        {
            stk=new StringTokenizer(nextLine());
            return nextToken();

        }
        return stk.nextToken();
    }

    public static void main(String[]args) throws Exception
    {
        new D().run();
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class D140 {

	private void Solution() throws IOException {
		int n = nextInt();
		int[] time = new int[n];
		for (int i = 0; i < n; i++)
			time[i] = nextInt();
		Arrays.sort(time);
		int up = 0, down = 0, before = 0, total = 0;
		for (int i = 0; i < n; i++) {
			if (total + time[i] <= 710) {
				up++;
				total += time[i];
			}
			if (before + time[i] <= 350) {
				down++;
				before += time[i];
			}
		}
		time[down] += before - 350;
		int ans = 0, cur = 0;
		for (int i = down; i < up; i++) {
			cur += time[i];
			ans += cur;
		}
		println(up, ans);
	}

	public static void main(String[] args) {
		new D140().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tokenizer;

	public void run() {
		try {
			String file = "";
			file = "system";
			if (file.equals("system")) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else if (file.equals("")) {
				in = new BufferedReader(new FileReader(new File("input.txt")));
				out = new PrintWriter(new File("output.txt"));
			} else {
				in = new BufferedReader(new FileReader(new File(file + ".in")));
				out = new PrintWriter(new File(file + ".out"));
			}
			tokenizer = null;
			Solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	void print(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(o[i]);
		}
	}

	void println(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(o[i]);
		}
		out.println();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(in.readLine());
		return tokenizer.nextToken();
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class D140 {

	private void Solution() throws IOException {
		int n = nextInt(), ans = 0;
		int[] time = new int[n];
		for (int i = 0; i < n; i++)
			time[i] = nextInt();
		Arrays.sort(time);
		int up = 0, down = 0, before = 0, total = 0;
		for (int i = 0; i < n; i++) {
			if (total + time[i] <= 710) {
				up++;
				total += time[i];
			}
			if (before + time[i] <= 350) {
				down++;
				before += time[i];
			}
		}
		if (up > down) {
			time[down] += before - 350;
			int cur = 0;
			for (int i = down; i < up; i++) {
				cur += time[i];
				ans += cur;
			}
		}
		println(up, ans);
	}

	public static void main(String[] args) {
		new D140().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tokenizer;

	public void run() {
		try {
			String file = "";
			file = "system";
			if (file.equals("system")) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else if (file.equals("")) {
				in = new BufferedReader(new FileReader(new File("input.txt")));
				out = new PrintWriter(new File("output.txt"));
			} else {
				in = new BufferedReader(new FileReader(new File(file + ".in")));
				out = new PrintWriter(new File(file + ".out"));
			}
			tokenizer = null;
			Solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	void print(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(o[i]);
		}
	}

	void println(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(o[i]);
		}
		out.println();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(in.readLine());
		return tokenizer.nextToken();
	}
}


/**
 * Created by IntelliJ IDEA.
 * User: mac
 * Date: 12-1-4
 * Time: 下午10:57
 * To change this template use File | Settings | File Templates.
 */

import java.io.*;
import java.util.*;

public class d {

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(reader.readLine());
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = nextInt();
        }

        Arrays.sort(a);

        int cur = 10;
        int num = 0, time = 0;
        for (int i : a) {
            if (cur + i <= 360) {
                cur += i;
                ++num;
            } else if (cur + i <= 720) {
                cur += i;
                ++num;
                time += Math.abs(cur - 360);
            }
        }

        System.out.println(num + " " + time);
    }

    static public void main(String[] args) {
        new d().run();
    }
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Map.Entry;

public class Solution implements Runnable {

	public static void main(String[] args) {
		(new Thread(new Solution())).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String r = in.readLine();
			if (r == null) return null;
			st = new StringTokenizer(r);
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	void solve() throws Exception {
		int n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = nextInt();
		Arrays.sort(a);
		int time = 10;
		int task = 0;
		int pen = 0;
		int q = 0;
		while (q < n) {
			if (time + a[q] > 720) break;
			time += a[q++];
			task++;
			pen += Math.max(0, time - 360);
		}
		out.println(task + " " + pen);
	}

	public void run() {
		Locale.setDefault(Locale.UK);
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
//			in = new BufferedReader(new FileReader("input.txt"));
//			out = new PrintWriter("output.txt");
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.flush();
		}
	}

}


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

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

        int n = r.nextInt();

        int[] a = new int[n];
        for(int i = 0; i < n; i++)
            a[i] = r.nextInt();

        Arrays.sort(a);
        int acc = 10;
        int p = 0;
        int accepted = 0;
        for(int i = 0; i < n; i++){
            acc += a[i];
            if(acc > 720){
                break;
            }else{
                accepted++;
            }

            if(acc > 360){
                p += acc - 360;
            }
        }

        System.out.println(accepted + " " + p);
    }
}


import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;

public class D {
	Scanner sc = new Scanner(System.in);

	int INF = 1 << 29;

	void run() {
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = sc.nextInt();
		sort(a);
		int[][] dp = new int[n + 1][711];
		for (int i = 0; i <= n; i++) fill(dp[i], INF);
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = n - 1; j >= 0; j--) {
				for (int k = 0; k + a[i] <= 710; k++) {
					int cost = max(0, k + a[i] - 350);
					if (dp[j + 1][k + a[i]] > dp[j][k] + cost) {
						dp[j + 1][k + a[i]] = dp[j][k] + cost;
					}
				}
			}
		}
		for (int i = n; i >= 0; i--) {
			for (int j = 0; j <= 710; j++) if (dp[i][j] < INF) {
				System.out.println(i + " " + dp[i][j]);
				return;
			}
		}
	}

	void debug(Object...os) {
		System.err.println(deepToString(os));
	}

	public static void main(String[] args) {
		new D().run();
	}
}


import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Main().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");
	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		in.close();
		out.close();
	}

	void solve() throws IOException{
		int n = nextInt();
		int m[] = new int[n];
		for(int i = 0; i < n; i++)
			m[i] = nextInt();
		sort(m);
		int curT = 0;
		int cnt = 0;
		int pen = 0;
		for(int i = 0; i < n; i++){
			if(curT + m[i] > 710) break;
			curT += m[i];
			cnt++;
			pen += curT < 350 ? 0 : curT - 350;
		}
		out.println(cnt + " " + pen);
	}

	void chk(boolean b) {
		if (b)
			return;
		System.out.println(new Error().getStackTrace()[1]);
		exit(999);
	}
	void deb(String fmt, Object... args) {
		System.out.printf(Locale.US, fmt + "%n", args);
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}


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

import java.util.regex.*;

public class problem{

    public static void main(String[] args) {
    	Scanner scan = new Scanner(System.in);
    	int n=scan.nextInt();
    	int[] a=new int[n];
    	for(int i=0;i<n;i++)
    	{
    		a[i]=scan.nextInt();
    	}
    	Arrays.sort(a);
    	int s=0,t=10,m=0;
    	for(int i=0;i<n;i++)
    	{
    		t+=a[i];
    		//System.out.println(a[i]);
    		if(t>720)break;
    		m++;
    		if(t>360)s+=t-360;
    	}
    	System.out.print(m);
    	System.out.print(" ");
    	System.out.print(s);
    }
 }


import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Egor Kulikov (egor@egork.net)
 */
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);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int count = in.readInt();
		int[] time = IOUtils.readIntArray(in, count);
		Arrays.sort(time);
		int solved = 0;
		int penalty = 0;
		int currentTime = 10;
		for (int i : time) {
			currentTime += i;
			if (currentTime > 720)
				break;
			solved++;
			penalty += Math.max(0, currentTime - 360);
		}
		out.printLine(solved, penalty);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	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 readInt() {
		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 static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	}

class OutputWriter {
	private final PrintWriter writer;

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

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

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

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

	}

class IOUtils {

	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readInt();
		return array;
	}

	}


import java.util.*;
public class D {
    D(Scanner in) {
        int N = in.nextInt();
        int[] time = new int[N];
        for (int i=0; i<N; i++)
            time[i] = in.nextInt();
        Arrays.sort(time);
        int curTime = 10;
        int probSolved = 0;
        int pp = 0;
        int curProb = 0;
        while(curTime <= 60*12 && curProb < N) {
            curTime += time[curProb++];
            if (curTime <= 60*12) {
                probSolved++;
                if (curTime > 60*6)
                    pp += curTime - 60*6;
            }
        }
        System.out.println(probSolved + " " + pp);
    }
    public static void main(String[] args) {
        new D(new Scanner(System.in));
    }
}


import java.util.*;
public class D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] array = new int[N];
        for(int a=0;a<N;a++){
            array[a]=sc.nextInt();
        }
        Arrays.sort(array);
        int prob = 0;
        int pen = 0;
        int time = (-(60*6))+10;
        int other = 0;
        for(int a=0;a<N;a++){
            time+=array[a];
            prob++;
            other = a;
            if(time>=0){pen+=time;
            break;}
        }
        for(int b=other+1;b<N;b++){
            int temp = time+array[b];
            if(temp<=(60*6)){
                prob++;
                time=temp;
                pen+=temp;
            }
        }

        System.out.println(prob+" "+pen);
    }

}


import java.util.*;
public class D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] array = new int[N];
        for(int a=0;a<N;a++){
            array[a]=sc.nextInt();
        }
        Arrays.sort(array);
        int prob = 0;
        int pen = 0;
        int time = (-(60*6))+10;
        int other = 0;
        for(int a=0;a<N;a++){
            time+=array[a];
            prob++;
            other = a;
            if(time>=0){pen+=time;
            break;}
        }
        for(int b=other+1;b<N;b++){
            int temp = time+array[b];
            if(temp<(60*6)){
                prob++;
                time=temp;
                pen+=temp;
            }
        }

        System.out.println(prob+" "+pen);
    }

}


import java.util.*;
public class D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] array = new int[N];
        for(int a=0;a<N;a++){
            array[a]=sc.nextInt();
        }
        Arrays.sort(array);
        int prob = 0;
        int pen = 0;
        int time = (-(60*6))+10;
    //  System.out.println(time);
        int other = 0;
        for(int a=0;a<N;a++){
            time+=array[a];
            prob++;
            other = a;
            if(time>360){
                System.out.println((prob-1)+" "+0);
                System.exit(0);

            }
            if(time>=0){pen+=time;
            break;}
        }
        for(int b=other+1;b<N;b++){
            int temp = time+array[b];
            if(temp<=(60*6)){
                prob++;
                time=temp;
                pen+=temp;
            }
        }

        System.out.println(prob+" "+pen);
    }

}


import java.util.*;
public class D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] array = new int[N];
        for(int a=0;a<N;a++){
            array[a]=sc.nextInt();
        }
        Arrays.sort(array);
        int prob = 0;
        int pen = 0;
        int time = (-(60*6))+10;
        int other = 0;
        for(int a=0;a<N;a++){
            time+=array[a];
            prob++;
            other = a;
            if(time>=0)pen+=time;
            break;
        }
        for(int b=other+1;b<N;b++){
            int temp = time+array[b];
            if(temp<(60*6)){
                prob++;
                time=temp;
                pen+=temp;
            }
        }

        System.out.println(prob+" "+pen);
    }

}


#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int letra[26];
string s;

int maior = 0;
int dp[1001];
int dp1[1001];

int f(int n) {
	int q = 0;

	dp[0] = 1;
	dp1[0] = 0;

	for (int i = 1; i <= n; i++) {

		int v = 0;
		dp1[i] = n;

		for (int j = i-1; j >= 0; j--) {
			v = max(v, i-letra[s[j]-'a']);

			if (v > j )
				continue;

			dp[i] = (dp[i]+dp[j])%mod;
			dp1[i] = min(dp1[i], 1+dp1[j]);
			maior = max(maior, i-j);
		}
	}

	return dp[n];
}

int main () {

	int n;

	scanf("%d", &n);
	cin >> s;

	for (int i = 0; i < 26; i++) {
		scanf("%d", &letra[i]);
	}

	printf("%d\n", f(n));
	printf("%d\n", maior);
	printf("%d\n", dp1[n]);

	return 0;
}


#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int letra[26];
string s;

int maior = 0;
int dp[1001];
int dp1[1001];

int f(int n) {
	int q = 0;

	dp[0] = 1;
	dp1[0] = 0;

	for (int i = 1; i <= n; i++) {

		int v = 0;
		dp1[i] = n;

		for (int j = i-1; j >= 0; j--) {
			v = max(v, i-letra[s[j]-'a']);

			if (v <= j ) {
				dp[i] = dp[i]+dp[j];
				dp1[i] = min(dp1[i], 1+dp1[j]);
				maior = max(maior, i-j);
			} else {
				continue;
			}
		}
	}

	return dp[n];
}

int main () {

	int n;

	scanf("%d", &n);
	cin >> s;

	for (int i = 0; i < 26; i++) {
		scanf("%d", &letra[i]);
	}

	printf("%d\n", f(n));
	printf("%d\n", maior);
	printf("%d\n", dp1[n]);

	return 0;
}


#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int letra[26];
string s;

int maior = 0;
int dp[1001];
int dp1[1001];

int f(int n) {
	int q = 0;

	dp[0] = 1;
	dp1[0] = 0;

	for (int i = 1; i <= n; i++) {

		int v = 0;
		dp1[i] = n;

		for (int j = i-1; j >= 0; j--) {
			v = max(v, i-letra[s[j]-'a']);

			if (v > j )
				continue;

			dp[i] = dp[i]+dp[j];
			dp1[i] = min(dp1[i], 1+dp1[j]);
			maior = max(maior, i-j);
		}
	}

	return dp[n];
}

int main () {

	int n;

	scanf("%d", &n);
	cin >> s;

	for (int i = 0; i < 26; i++) {
		scanf("%d", &letra[i]);
	}

	printf("%d\n", f(n));
	printf("%d\n", maior);
	printf("%d\n", dp1[n]);

	return 0;
}


#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int letra[26];
string s;

int maior = 0;
int dp[1001];
int dp1[1001];

int f(int n) {
	int q = 0;

	dp[0] = 1;
	dp1[0] = 0;

	for (int i = 1; i <= n; i++) {

		int v = 0;
		dp1[i] = n;

		for (int j = i-1; j >= 0; j--) {
			v = max(v, i-letra[s[j]-'a']);

			if (v <= j ) {
				dp[i] = (dp[i]+dp[j])%mod;
				dp1[i] = min(dp1[i], 1+dp1[j]);
				maior = max(maior, i-j);
			}
		}
	}

	return dp[n];
}

int main () {

	int n;

	scanf("%d", &n);
	cin >> s;

	for (int i = 0; i < 26; i++) {
		scanf("%d", &letra[i]);
	}

	printf("%d\n", f(n));
	printf("%d\n", maior);
	printf("%d\n", dp1[n]);

	return 0;
}


#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int letra[26];
string s;

int maior = 0;
int dp[1001];
int dp1[1001];

int f(int n) {
	int q = 0;

	dp[0] = 1;
	dp1[0] = 0;

	for (int i = 1; i <= n; i++) {

		int v = 0;
		dp1[i] = n;

		for (int j = i-1; j >= 0; j--) {
			v = max(v, i-letra[s[j]-'a']);

			if (v <= j ) {
				dp[i] = (dp[i]+dp[j])%mod;
				dp1[i] = min(dp1[i], 1+dp1[j]);
				maior = max(maior, i-j);
			} else {
				break;
			}
		}
	}

	return dp[n];
}

int main () {

	int n;

	scanf("%d", &n);
	cin >> s;

	for (int i = 0; i < 26; i++) {
		scanf("%d", &letra[i]);
	}

	printf("%d\n", f(n));
	printf("%d\n", maior);
	printf("%d\n", dp1[n]);

	return 0;
}


#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int letra[26];
string s;

int maior = 0;
int dp[1001];
int dp1[1001];

int f(int n) {
	int q = 0;

	dp[0] = 1;
	dp1[0] = 0;

	for (int i = 1; i <= n; i++) {

		int v = 0;
		dp1[i] = n;

		for (int j = i-1; j >= 0; j--) {
			v = max(v, i-letra[s[j]-'a']);

			if (v <= j ) {
				dp[i] = dp[i]+dp[j];
				dp1[i] = min(dp1[i], 1+dp1[j]);
				maior = max(maior, i-j);
			} else {
				break;
			}
		}
	}

	return dp[n];
}

int main () {

	int n;

	scanf("%d", &n);
	cin >> s;

	for (int i = 0; i < 26; i++) {
		scanf("%d", &letra[i]);
	}

	printf("%d\n", f(n));
	printf("%d\n", maior);
	printf("%d\n", dp1[n]);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
int dp[300];
char s[300];
int a[30];
int xin[300];
bool judge(int i,int j){
	int l=j-i+1;
	for(int k=i;k<=j;k++){
		if(a[s[k]-'a']<l)
		return false;
	}
	return true;
}
int main(){
    int mix=1;
    int n;
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=0;i<26;i++)
        scanf("%d",&a[i]);
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    xin[0]=0;
    for(int i=1;i<=n;i++){
        xin[i]=inf;
        for(int j=1;j<=i;j++){
            if(judge(i-j+1,i)){
                dp[i]=(dp[i]+dp[i-j])%mod;
                xin[i]=min(xin[i],xin[i-j]+1);
                if(dp[i-j])
                mix=max(mix,j);
            }
        }
    }
    cout<<dp[n]<<endl;
    cout<<mix<<endl;
    cout<<xin[n]<<endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
long long dp[300];
char s[300];
int xin[300];
int a[30];
bool judge(int i,int j){
	int l=j-i+1;
	for(int k=i;k<=j;k++){
		if(a[s[k]-'a']<l)
		return false;
	}
	return true;
}
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=0;i<26;i++){
        scanf("%d",&a[i]);
    }
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    xin[0]=0;
    int mix=1;
    for(int i=1;i<=n;i++){
        xin[i]=inf;
        for(int j=1;j<=i;j++){
            if(judge(i-j+1,i)){
                dp[i]=(dp[i]+dp[i-j])%mod;
                xin[i]=min(xin[i],xin[i-j]+1);
                if(dp[i-j])
                mix=max(mix,j);
            }
        }
    }
    cout<<dp[n]<<endl;
    cout<<mix<<endl;
    cout<<xin[n]<<endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
long long dp[300];
char s[300];
int a[30];
int xin[300];
bool judge(int i,int j){
	int l=j-i+1;
	for(int k=i;k<=j;k++){
		if(a[s[k]-'a']<l)
		return false;
	}
	return true;
}
int main(){
    int n;
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    xin[0]=0;
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=0;i<26;i++){
        scanf("%d",&a[i]);
    }
    int mix=1;
    for(int i=1;i<=n;i++){
        xin[i]=inf;
        for(int x=1;x<=i;x++){
            int l=i-x+1;
            if(judge(l,i)){
                dp[i]+=dp[i-x];
                dp[i]%=mod;
                xin[i]=min(xin[i],xin[i-x]+1);
                if(dp[i-x])
                    mix=max(mix,x);
            }
        }
    }
    printf("%d\n",dp[n]);
    printf("%d\n",mix);
    printf("%d\n",xin[n]);
    return 0;
}