import java.util.*;

import java.io.*;

public class gg {

	public static void main(String[] args) {

		// TODO Auto-generated method stub

		FastInputReader s = new FastInputReader();
		int n = s.nextInt();
		int[] arr = new int[n];
		int[] freq = new int[100001];
		int[] freq2 = new int[100001];
		for (int i = 0; i < n; i++) {
			arr[i] = s.nextInt();
			if (arr[i] != 0) {
				if (arr[i] > 0) {
					freq[arr[i]]++;
				} else {
					freq2[-1 * arr[i]]++;
				}
			}
		}
		long count = 0;
		for (int i = 0; i < 100001; i++) {
			if (freq[i] != 0) {
				count++;
			}
			if (freq2[i] != 0) {
				count++;
			}
		}
		System.out.println(count);

	}

	public static class FastInputReader {

		private byte[] buf = new byte[16384];

		private int curChar;

		private int numChars;

		public int read() {

			if (numChars == -1)

				throw new InputMismatchException();

			if (curChar >= numChars) {

				curChar = 0;

				try {

					numChars = System.in.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 nextString() {

			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 nextLong() {

			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 nextInt() {

			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 int[] nextIntArray(int n) {

			int[] arr = new int[n];

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

				arr[i] = nextInt();

			}

			return arr;

		}

		public long[] nextLongArray(int n) {

			long[] arr = new long[n];

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

				arr[i] = nextLong();

			}

			return arr;

		}

		private boolean isSpaceChar(int c) {

			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;

		}

		private boolean isEndOfLine(int c) {

			return c == '\n' || c == '\r' || c == -1;

		}

	}

	public static class MyScanner {

		BufferedReader reader;

		public MyScanner() {

			this.reader = new BufferedReader(new InputStreamReader(System.in));

		}

		public void close() throws IOException {

			this.reader.close();

		}

		int nextInt() {

			return Integer.parseInt(this.next());

		}

		long nextLong() {

			return Long.parseLong(this.next());

		}

		float nextFloat() {

			return Float.parseFloat(this.next());

		}

		double nextDouble() {

			return Double.parseDouble(this.next());

		}

		String next() {

			String str = "";

			try {

				str = this.reader.readLine().trim();

			} catch (IOException e) {

				e.printStackTrace();

			}

			return str;

		}

		String[] nextStringArray() {

			String[] str = null;

			try {

				str = this.reader.readLine().trim().split(" ");

			} catch (IOException e) {

				e.printStackTrace();

			}

			return str;

		}

		int[] nextIntArray() {

			String[] data = nextStringArray();

			int[] a = new int[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Integer.parseInt(data[i]);

			}

			return a;

		}

		Integer[] nextIntegerArray() {

			String[] data = nextStringArray();

			Integer[] a = new Integer[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Integer.parseInt(data[i]);

			}

			return a;

		}

		long[] nextLongArray() {

			String[] data = nextStringArray();

			long[] a = new long[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Long.parseLong(data[i]);

			}

			return a;

		}

		float[] nextFloatArray() {

			String[] data = nextStringArray();

			float[] a = new float[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Float.parseFloat(data[i]);

			}

			return a;

		}

		double[] nextDoubleArray() {

			String[] data = nextStringArray();

			double[] a = new double[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Double.parseDouble(data[i]);

			}

			return a;

		}

	}

}


import java.util.*;

import java.io.*;

public class gg {

	public static void main(String[] args) {

		// TODO Auto-generated method stub

		FastInputReader s = new FastInputReader();
		int n = s.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++) {
			arr[i] = s.nextInt();

		}
		long count=0;
		for(int i=0;i<n;i++) {
			if(arr[i]!=0) {
				count++;
			}
		}
		System.out.println(count);

	}

	public static class FastInputReader {

		private byte[] buf = new byte[16384];

		private int curChar;

		private int numChars;

		public int read() {

			if (numChars == -1)

				throw new InputMismatchException();

			if (curChar >= numChars) {

				curChar = 0;

				try {

					numChars = System.in.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 nextString() {

			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 nextLong() {

			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 nextInt() {

			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 int[] nextIntArray(int n) {

			int[] arr = new int[n];

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

				arr[i] = nextInt();

			}

			return arr;

		}

		public long[] nextLongArray(int n) {

			long[] arr = new long[n];

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

				arr[i] = nextLong();

			}

			return arr;

		}

		private boolean isSpaceChar(int c) {

			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;

		}

		private boolean isEndOfLine(int c) {

			return c == '\n' || c == '\r' || c == -1;

		}

	}

	public static class MyScanner {

		BufferedReader reader;

		public MyScanner() {

			this.reader = new BufferedReader(new InputStreamReader(System.in));

		}

		public void close() throws IOException {

			this.reader.close();

		}

		int nextInt() {

			return Integer.parseInt(this.next());

		}

		long nextLong() {

			return Long.parseLong(this.next());

		}

		float nextFloat() {

			return Float.parseFloat(this.next());

		}

		double nextDouble() {

			return Double.parseDouble(this.next());

		}

		String next() {

			String str = "";

			try {

				str = this.reader.readLine().trim();

			} catch (IOException e) {

				e.printStackTrace();

			}

			return str;

		}

		String[] nextStringArray() {

			String[] str = null;

			try {

				str = this.reader.readLine().trim().split(" ");

			} catch (IOException e) {

				e.printStackTrace();

			}

			return str;

		}

		int[] nextIntArray() {

			String[] data = nextStringArray();

			int[] a = new int[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Integer.parseInt(data[i]);

			}

			return a;

		}

		Integer[] nextIntegerArray() {

			String[] data = nextStringArray();

			Integer[] a = new Integer[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Integer.parseInt(data[i]);

			}

			return a;

		}

		long[] nextLongArray() {

			String[] data = nextStringArray();

			long[] a = new long[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Long.parseLong(data[i]);

			}

			return a;

		}

		float[] nextFloatArray() {

			String[] data = nextStringArray();

			float[] a = new float[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Float.parseFloat(data[i]);

			}

			return a;

		}

		double[] nextDoubleArray() {

			String[] data = nextStringArray();

			double[] a = new double[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Double.parseDouble(data[i]);

			}

			return a;

		}

	}

}


import java.util.*;

import java.io.*;

public class gg {

	public static void main(String[] args) {

		// TODO Auto-generated method stub

		FastInputReader s = new FastInputReader();
		int n = s.nextInt();
		int[] arr = new int[n];
		int[] freq = new int[n + 1];
		int[] freq2 = new int[n + 1];
		for (int i = 0; i < n; i++) {
			arr[i] = s.nextInt();
			if (arr[i] != 0) {
				if (arr[i] > 0) {
					freq[arr[i]]++;
				} else {
					freq2[-1 * arr[i]]++;
				}
			}
		}
		long count = 0;
		for (int i = 0; i < n + 1; i++) {
			if (freq[i] != 0) {
				count++;
			}
			if (freq2[i] != 0) {
				count++;
			}
		}
		System.out.println(count);

	}

	public static class FastInputReader {

		private byte[] buf = new byte[16384];

		private int curChar;

		private int numChars;

		public int read() {

			if (numChars == -1)

				throw new InputMismatchException();

			if (curChar >= numChars) {

				curChar = 0;

				try {

					numChars = System.in.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 nextString() {

			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 nextLong() {

			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 nextInt() {

			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 int[] nextIntArray(int n) {

			int[] arr = new int[n];

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

				arr[i] = nextInt();

			}

			return arr;

		}

		public long[] nextLongArray(int n) {

			long[] arr = new long[n];

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

				arr[i] = nextLong();

			}

			return arr;

		}

		private boolean isSpaceChar(int c) {

			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;

		}

		private boolean isEndOfLine(int c) {

			return c == '\n' || c == '\r' || c == -1;

		}

	}

	public static class MyScanner {

		BufferedReader reader;

		public MyScanner() {

			this.reader = new BufferedReader(new InputStreamReader(System.in));

		}

		public void close() throws IOException {

			this.reader.close();

		}

		int nextInt() {

			return Integer.parseInt(this.next());

		}

		long nextLong() {

			return Long.parseLong(this.next());

		}

		float nextFloat() {

			return Float.parseFloat(this.next());

		}

		double nextDouble() {

			return Double.parseDouble(this.next());

		}

		String next() {

			String str = "";

			try {

				str = this.reader.readLine().trim();

			} catch (IOException e) {

				e.printStackTrace();

			}

			return str;

		}

		String[] nextStringArray() {

			String[] str = null;

			try {

				str = this.reader.readLine().trim().split(" ");

			} catch (IOException e) {

				e.printStackTrace();

			}

			return str;

		}

		int[] nextIntArray() {

			String[] data = nextStringArray();

			int[] a = new int[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Integer.parseInt(data[i]);

			}

			return a;

		}

		Integer[] nextIntegerArray() {

			String[] data = nextStringArray();

			Integer[] a = new Integer[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Integer.parseInt(data[i]);

			}

			return a;

		}

		long[] nextLongArray() {

			String[] data = nextStringArray();

			long[] a = new long[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Long.parseLong(data[i]);

			}

			return a;

		}

		float[] nextFloatArray() {

			String[] data = nextStringArray();

			float[] a = new float[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Float.parseFloat(data[i]);

			}

			return a;

		}

		double[] nextDoubleArray() {

			String[] data = nextStringArray();

			double[] a = new double[data.length];

			for (int i = 0; i < a.length; i++) {

				a[i] = Double.parseDouble(data[i]);

			}

			return a;

		}

	}

}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 *
 * @author ritwik.shanker
 */
public class A992
{
    public static
            void main(String[] args)
    {
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int a[]=new int[n];
        Set<Integer> set=new HashSet<>();
        for(int i=0;i<n;i++)
        {
            set.add(scn.nextInt());
        }
        set.remove(0);
        System.out.println(set.size());
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 *
 * @author ritwik.shanker
 */
public class A992
{
    public static
            void main(String[] args)
    {
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int a[]=new int[n];
        Set<Integer> set=new HashSet<>();
        for(int i=0;i<n;i++)
        {
            set.add(scn.nextInt());
        }
        set.remove(0);
        System.out.println(set.size());
    }
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class A {
    private static int[] arr;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        arr = new int[length];
        for (int i = 0; i < length; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int countOfExclusive = 0;
        for (int i = 0; i < length; i++) {
            if (arr[i] == 0) continue;
            countOfExclusive++;
            int curr = i;
            while (arr[curr] == arr[i]) {
                i++;
                if (i == length) break;
            }
            i--;
        }
        System.out.println(countOfExclusive);
    }

}


import java.util.ArrayList;
import java.util.Scanner;

public class A {
    private static short[] arr;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        short length = sc.nextShort();
        arr = new short[length];
        for (int i = 0; i < length; i++) {
            arr[i] = sc.nextShort();
        }
        ArrayList<Short> list = new ArrayList<>();
        for (short i : arr) {
            if (i == 0 || list.contains(i)) continue;
            list.add(i);
        }
        System.out.println(list.size());
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class A {
    private static int[] arr;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        arr = new int[length];
        for (int i = 0; i < length; i++) {
            arr[i] = sc.nextInt();
        }
        ArrayList<Integer> list = new ArrayList<>();
        for (int i : arr) {
            if (i == 0) continue;
            if (list.contains(i)) continue;
            list.add(i);
        }
        System.out.println(list.size());
    }

//    private static int odinakovych() {
//
//    }
//
//    private static int bezNuley() {
//        int nuli = 0;
//        for (int i : arr) {
//            if (i == 0) nuli++;
//        }
//        return arr.length-nuli;
//    }
}


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

@SuppressWarnings("unchecked")
public class P992A {

  final static int ADD = 100_000;

  public void run() throws Exception {
    BitSet bs = new BitSet();
    for (int n = nextInt(); n > 0; bs.set(nextInt() + ADD), n--);
    bs.clear(ADD);
    println(bs.cardinality());
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P992A().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Integer.numberOfTrailingZeros(a), bz = Integer.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Integer.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Integer.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  long gcd(long a, long b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Long.numberOfTrailingZeros(a), bz = Long.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Long.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Long.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  void shuffle(int [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      int t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(long [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      long t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }
}


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

@SuppressWarnings("unchecked")
public class P992A {

  public void run() throws Exception {
    Set<Integer> s = new HashSet();
    for (int n = nextInt(); n > 0; s.add(nextInt()), n--);
    s.remove(0);
    println(s.size());
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P992A().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Integer.numberOfTrailingZeros(a), bz = Integer.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Integer.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Integer.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  long gcd(long a, long b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Long.numberOfTrailingZeros(a), bz = Long.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Long.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Long.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  void shuffle(int [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      int t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(long [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      long t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }
}


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

@SuppressWarnings("unchecked")
public class P992A {

  final static int ADD = 100_000;

  public void run() throws Exception {
    BitSet bs = new BitSet(ADD + ADD + 1);
    for (int n = nextInt(); n > 0; bs.set(nextInt() + ADD), n--);
    bs.clear(ADD);
    println(bs.cardinality());
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P992A().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Integer.numberOfTrailingZeros(a), bz = Integer.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Integer.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Integer.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  long gcd(long a, long b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Long.numberOfTrailingZeros(a), bz = Long.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Long.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Long.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  void shuffle(int [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      int t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(long [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      long t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }
}


import java.util.Scanner;

public class CF992A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int[] numbers = new int[number];
        for (int i = 0; i < number; i++) {
            numbers[i] = scanner.nextInt();
        }
        int diff = 0;
        int seconds = 0;
        for (int i = 0; i < number; i++) {
            if (numbers[i] !=0 && numbers[i] - diff != 0 ) {
                seconds++;
                diff+= numbers[i] - diff;
            }
        }
        System.out.println(seconds);
    }
}


import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF992A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int[] changedToZero = new int[200001];
        int seconds = 0;
        for (int i = 0; i < number; i++) {
            int newNumber = scanner.nextInt();
            if (newNumber != 0) {
                if (changedToZero[newNumber+100000] == 0) {
                    changedToZero[newNumber+100000] =1;
                    seconds++;
                }
            }
        }
        System.out.println(seconds);
    }
}


import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF992A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        ArrayList<Integer> numbers = new ArrayList<>();
        for (int i = 0; i < number; i++) {
            int newNumber = scanner.nextInt();
            if (newNumber !=0 && numbers.indexOf(newNumber) < 0) {
                numbers.add(newNumber);
            }
        }
        int seconds = 0;
        for (int i=0; i< numbers.size(); i++) {
            seconds++;
            int j = i + 1;
            while (j < numbers.size()) {
                numbers.set(j, numbers.get(j) - numbers.get(i));
                if (numbers.get(j) == 0) {
                    numbers.remove(j);
                } else {
                    j++;
                }
            }
        }
        System.out.println(seconds);
    }
}


import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF992A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        ArrayList<Integer> numbers = new ArrayList<>();
        ArrayList<Integer> discountedAmmount = new ArrayList<>();
        int seconds = 0;
        for (int i = 0; i < number; i++) {
            int newNumber = scanner.nextInt();
            if (newNumber != 0 && numbers.indexOf(newNumber) < 0) {
                if (discountedAmmount.indexOf(newNumber) < 0) {
                    seconds++;
                    if (discountedAmmount.size() == 0) {
                        discountedAmmount.add(newNumber);
                    } else {
                        discountedAmmount.add(discountedAmmount.get(discountedAmmount.size() - 1) + newNumber);

                    }
                }
            }
        }
        System.out.println(seconds);
    }
}


import java.util.Scanner;

public class CF992A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int[] numbers = new int[number];
        for (int i = 0; i < number; i++) {
            numbers[i] = scanner.nextInt();
        }
        int diff = 0;
        int seconds = 0;
        for (int i = 0; i < number; i++) {
            if (numbers[i] !=0 ) {
                seconds++;
                //diff+= numbers[i] - diff;
                for (int j = i + 1; j < number; j++) {
                    if (numbers[j] != 0) {
                        numbers[j] = numbers[j] - numbers[i];
                    }
                }
                numbers[i] = 0;
            }
        }
        System.out.println(seconds);
    }
}


import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF992A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        ArrayList<Integer> numbers = new ArrayList<>();
        ArrayList<Integer> discountedAmmount = new ArrayList<>();
        for (int i = 0; i < number; i++) {
            int newNumber = scanner.nextInt();
            if (newNumber !=0 && numbers.indexOf(newNumber) < 0) {
                numbers.add(newNumber);
            }
        }
        int seconds = 0;
        for (int i=0; i< numbers.size(); i++) {
            if (discountedAmmount.indexOf(numbers.get(i)) < 0) {
                seconds++;
                if (discountedAmmount.size() == 0) {
                    discountedAmmount.add(numbers.get(i));
                } else {
                    discountedAmmount.add(discountedAmmount.get(discountedAmmount.size() - 1) + numbers.get(i));

                }
            }
        }
        System.out.println(seconds);
    }
}


import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF992A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        ArrayList<Integer> discountedAmmount = new ArrayList<>();
        int seconds = 0;
        for (int i = 0; i < number; i++) {
            int newNumber = scanner.nextInt();
            if (newNumber != 0) {
                if (discountedAmmount.indexOf(newNumber) < 0) {
                    seconds++;
                    discountedAmmount.add(newNumber);
                }
            }
        }
        System.out.println(seconds);
    }
}


//package CodeForces.A;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Task992A {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++){
            a[i]=scn.nextInt();
        }
        Set<Integer> set = new HashSet<>();
        set.add(0);
        int kol = 0;
        for(int i = 0; i<n; i++){
            if(!set.contains(a[i])){
                kol++;
                set.add(a[i]);
            }
        }
        System.out.println(kol);
    }
}


import java.util.Scanner;

public class A {
	public static void main(String[] args) {
		Nest aaa = new Nest();
		aaa.solve();
		aaa.print();
	}
}

class Nest {
	int n;
	int[] a;
	int current;
	int best;
	int count;

	Nest() {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		in.close();
	}

	void solve() {
		best = a[0];
		for (int m = 0; m < n; m++) {
			if (a[m] != 0) {
				for (int j = 0; j < n; j++) {
					current = a[j];
					if (current > best) {
						best = current;
					}
				}
				for (int i = 0; i < n; i++) {
					if (a[i] != 0 && best >= 0) {
						a[i] = a[i] - best;
					}
					if (a[i] != 0 && best < 0) {
						a[i] = a[i] + Math.abs(best);
					}
				}
				count++;
			}
		}
	}

	void print() {
		System.out.println(count);
	}
}


import java.util.Scanner;
import java.util.TreeSet;

public class A {
	public static void main(String[] args) {
		Nest aaa = new Nest();
	}
}
class Nest {
	int n;
	int count;
	Nest() {
		Scanner in = new Scanner(System.in);
		TreeSet<Integer> ts = new TreeSet<>();
		n = in.nextInt();
		for(int i=0; i<n; i++) {
			if(ts.add(in.nextInt())) {
				count++;
			}
			if(in.nextInt()==0) {
				count--;
			}
		}
		in.close();
		System.out.println(count);
	}
}


import java.util.Scanner;

public class A {
	public static void main(String[] args) {
		Nest aaa = new Nest();
		aaa.solve();
		aaa.print();
	}
}

class Nest {
	int n;
	int[] a;
	int current;
	int best;
	int count;

	Nest() {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		in.close();
	}

	void solve() {
		best = a[0];
		for (int m = 0; m < n; m++) {
			if (a[m] != 0) {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						current = a[j];
						if (current > best) {
							best = current;
						}
					}
					if (a[i] != 0 && best >= 0) {
						a[i] = a[i] - best;
					}
					if (a[i] != 0 && best < 0) {
						a[i] = a[i] + Math.abs(best);
					}
				}
				count++;
			}
		}
	}

	void print() {
		System.out.println(count);
	}
}


import java.util.Scanner;
import java.util.TreeSet;

public class A {
	public static void main(String[] args) {
		Nest aaa = new Nest();
		aaa.solve();
		aaa.print();
	}
}
class Nest {
	int n;
	int []a;
	int count;
	Nest() {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		a = new int [n];
		for(int i=0; i<n; i++) {
			a[i]=in.nextInt();
		}
		in.close();
	}
	void solve() {
		TreeSet<Integer> ts = new TreeSet<>();
		for(int i=0; i<n; i++) {
			if(ts.add(a[i]) && a[i]!=0) {
				count++;
			}
		}
	}
	void print() {
		System.out.println(count);
	}
}


import java.util.*;

public class helloWorld
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashSet<Integer> set = new HashSet<Integer>();

		for(int i = 0; i < n; i++) {
			int a = in.nextInt();
			if(a != 0)
				set.add(a);
		}

		System.out.println(set.size());

		in.close();
	}
}


import java.util.*;

public class helloWorld
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		ArrayList<Integer> ar = new ArrayList<Integer>();
		int ans = 1;

		for(int i = 0; i < n; i++) {
			int a = in.nextInt();
			if(a != 0)
				ar.add(i);
		}
		Collections.sort(ar);

		for(int i = 1; i < ar.size(); i++)
			if(ar.get(i-1) != ar.get(i))
				ans++;
		if(ar.size() == 0)
			ans = 0;

		System.out.println(ans);

		in.close();
	}
}


import java.util.*;

public class helloWorld
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		ArrayList<Integer> ar = new ArrayList<Integer>();
		int ans = 1;

		for(int i = 0; i < n; i++) {
			int a = in.nextInt();
			if(a != 0)
				ar.add(a);
		}
		Collections.sort(ar);

		for(int i = 1; i < ar.size(); i++)
			if(ar.get(i-1) != ar.get(i))
				ans++;
		if(ar.size() == 0)
			ans = 0;

		System.out.println(ans);

		in.close();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Set;
import java.util.TreeSet;

public class NastyaandanArray {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader tc = new BufferedReader(new InputStreamReader(System.in));
		Integer n = Integer.parseInt(tc.readLine());

		String[] array = tc.readLine().split(" ");
		Set<Integer> a = new TreeSet<>();

		for (int i = 0; i < array.length; i++) {
			int temp = Integer.parseInt(array[i]);
			if (temp != 0) {
				a.add(Integer.parseInt(array[i]));
			}
		}

		System.out.println(a.size());

	}

}


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

public class NastyaandanArray {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader tc = new BufferedReader(new InputStreamReader(System.in));
		Integer n = Integer.parseInt(tc.readLine());

		String[] array = tc.readLine().split(" ");
		int[] a = new int[array.length];
		for (int i = 0; i < array.length; i++) {
			a[i] = Integer.parseInt(array[i]);
		}

		int count = 0;
		for (int i = 0; i < n; i++) {
			int temp = a[i];
//			System.out.print(temp+" ");
			if (temp == 0) {
			} else {
				count++;
				for (int j = 0; j < a.length; j++) {
					if(a[j]!=0) {
						a[j] = a[j]-temp;
					}
				}
			}
		}

		System.out.println(count);

	}

}


import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.function.Predicate;

public class magicArray {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] magicArray = new int[n];
        int[] m = new int[n];
//        LinkedList<Integer> nonZero = new LinkedList<>();
        HashSet<Integer> nonZero = new HashSet<>();
        for(int i = 0; i < n; i++) {
            magicArray[i] = scanner.nextInt();
            if(magicArray[i] != 0)
                nonZero.add(magicArray[i]);
        }
//        int count = 0;
//        while(!nonZero.isEmpty()) {
//            int index = nonZero.getFirst();
//            nonZero.removeIf(new Predicate<Integer>() {
//                @Override
//                public boolean test(Integer integer) {
//                    return integer-index == 0 || integer == 0;
//                }
//            });
//            count++;
//        }
        System.out.println(nonZero.size());
    }
}


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.function.Predicate;

public class magicArray {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] magicArray = new int[n];
        int[] m = new int[n];
        LinkedList<Integer> nonZero = new LinkedList<>();
        for(int i = 0; i < n; i++) {
            magicArray[i] = scanner.nextInt();
            if(magicArray[i] != 0)
                nonZero.add(magicArray[i]);
        }
        int count = 0;
        while(!nonZero.isEmpty()) {
            int index = nonZero.getFirst();
            nonZero.removeIf(new Predicate<Integer>() {
                @Override
                public boolean test(Integer integer) {
                    return integer-index == 0 || integer == 0;
                }
            });
            count++;
        }
        System.out.println(count);
    }
}


import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] store = new int[200000];
        int inp, res=0;

        for(int i=0 ; i<n ; i++){
            inp = sc.nextInt();
            if(inp==0) continue;
            if(inp<0){
                inp=-inp;
                inp+=100000;
            }
//            System.out.println(inp);
            if(store[inp]==0)
                res++;
            store[inp]++;
        }

        System.out.println(res);
    }
}


import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] store = new int[200000];
        int inp, res=0;

        for(int i=0 ; i<n ; i++){
            inp = sc.nextInt();
            if(inp<0){
                inp=-inp;
                inp+=100000;
            }
//            System.out.println(inp);
            if(store[inp]==0)
                res++;
            store[inp]++;
        }

        System.out.println(res);
    }
}


import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] store = new int[200001];
        int inp, res=0;

        for(int i=0 ; i<n ; i++){
            inp = sc.nextInt();
            if(inp==0) continue;
            if(inp<0){
                inp=-inp;
                inp+=100000;
            }
//            System.out.println(inp);
            if(store[inp]==0)
                res++;
            store[inp]++;
        }

        System.out.println(res);
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author ajdana
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        int n;
        int[] arr;
        try (Scanner reader = new Scanner(System.in)) {
           // System.out.println("Enter a number: ");
            n = reader.nextInt();
            arr = new int[n];
          //  System.out.println("Enter array elements: ");
            for(int i=0; i<n; i++) {
                arr[i] = reader.nextInt();
            }
        }

        int time = countTime(arr, n);
        System.out.println(time);
    }

    private static int countTime(int[] arr, int n) {
        int[] vals = new int[n];

        for(int j=0; j<n; j++) {
             vals[j] = 0;
        }

        int k=0;
        int count=0;
        int val;
        boolean isFound;
        for(int i=0; i<n; i++) {
            isFound = false;
            val = arr[i];
            if(arr[i] == 0) {
               continue;
            } else {
                if(arr[i] < 0) {
                    arr[i] += arr[i];
                    for(int j=0; j<vals.length; j++) {
                        if(val == vals[j]) {
                            vals[k] = val;
                            isFound = true;
                            break;
                        }
                    }
                    if(isFound == false) {
                        count++;
                        vals[k] = val;
                    }
                }
                if(arr[i] > 0){
                    arr[i] += -arr[i];
                    for(int j=0; j<vals.length; j++) {
                        if(val == vals[j]) {
                            vals[k] = val;
                            isFound = true;
                            break;
                        }
                    }

                    if(isFound == false) {
                        count++;
                        vals[k] = val;
                    }
                }
            }
            k++;
        }
        return count;
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package algorithms_2;

import java.util.Scanner;

/**
 *
 * @author ajdana
 */
public class Algorithms_2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        int n;
        int[] arr;
        try (Scanner reader = new Scanner(System.in)) {
            System.out.println("Enter a number: ");
            n = reader.nextInt();
            arr = new int[n];
            System.out.println("Enter array elements: ");
            for(int i=0; i<n; i++) {
                arr[i] = reader.nextInt();
            }
        }

        int time = countTime(arr, n);
        System.out.println("Time = " + time);
    }

    private static int countTime(int[] arr, int n) {
        int[] vals = new int[n];

        for(int j=0; j<n; j++) {
             vals[j] = 0;
        }

        int k=0;
        int count=0;
        int val;
        boolean isFound;
        for(int i=0; i<n; i++) {
            isFound = false;
            val = arr[i];
            if(arr[i] == 0) {
               continue;
            } else {
                if(arr[i] < 0) {
                    arr[i] += arr[i];
                    for(int j=0; j<vals.length; j++) {
                        if(val == vals[j]) {
                            vals[k] = val;
                            isFound = true;
                            break;
                        }
                    }
                    if(isFound == false) {
                        count++;
                        vals[k] = val;
                    }
                }
                if(arr[i] > 0){
                    arr[i] += -arr[i];
                    for(int j=0; j<vals.length; j++) {
                        if(val == vals[j]) {
                            vals[k] = val;
                            isFound = true;
                            break;
                        }
                    }

                    if(isFound == false) {
                        count++;
                        vals[k] = val;
                    }
                }
            }
            k++;
        }

        return count;
    }

}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
     /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        int n;
        int[] arr;
        try (Scanner reader = new Scanner(System.in)) {
            n = reader.nextInt();
            arr = new int[n];
            for(int i=0; i<n; i++) {
                arr[i] = reader.nextInt();
            }
        }

        int time = countTime(arr, n);
        System.out.println(time);
    }

    private static int countTime(int[] arr, int n) {

        int count = 0;
        Set<Integer> set = new HashSet<Integer>();

        for(int j=0; j<n; j++) {
            if(!set.contains(arr[j])){
                set.add(arr[j]);
            }
        }

        if(set.contains(0)) {
            count = set.size() - 1;
        } else {
            count = set.size();
        }

        return count;

    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package algorithms_2;

import java.util.Scanner;

/**
 *
 * @author ajdana
 */
public class Algorithms_2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        int n;
        int[] arr;
        try (Scanner reader = new Scanner(System.in)) {
           // System.out.println("Enter a number: ");
            n = reader.nextInt();
            arr = new int[n];
          //  System.out.println("Enter array elements: ");
            for(int i=0; i<n; i++) {
                arr[i] = reader.nextInt();
            }
        }

        int time = countTime(arr, n);
        System.out.println(time);
    }

    private static int countTime(int[] arr, int n) {
        int[] vals = new int[n];

        for(int j=0; j<n; j++) {
             vals[j] = 0;
        }

        int k=0;
        int count=0;
        int val;
        boolean isFound;
        for(int i=0; i<n; i++) {
            isFound = false;
            val = arr[i];
            if(arr[i] == 0) {
               continue;
            } else {
                if(arr[i] < 0) {
                    arr[i] += arr[i];
                    for(int j=0; j<vals.length; j++) {
                        if(val == vals[j]) {
                            vals[k] = val;
                            isFound = true;
                            break;
                        }
                    }
                    if(isFound == false) {
                        count++;
                        vals[k] = val;
                    }
                }
                if(arr[i] > 0){
                    arr[i] += -arr[i];
                    for(int j=0; j<vals.length; j++) {
                        if(val == vals[j]) {
                            vals[k] = val;
                            isFound = true;
                            break;
                        }
                    }

                    if(isFound == false) {
                        count++;
                        vals[k] = val;
                    }
                }
            }
            k++;
        }

        return count;
    }

}


import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class Contetst {

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

		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt() ;

		int [] arr = new int [n] ;

		HashMap<Integer, Integer> map  =  new HashMap<>() ;

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

			if(!(map.containsKey(arr[i])) && arr[i]!=0 )
			{
				map.put(arr[i], 0);
			}
			else
			{
				continue ;
			}

		}

		System.out.println(map.size());

	}

}


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

public class Contetst {

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

		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt() ;
		int c = 0 ;
		int [] arr = new int [n] ;
		for (int i = 0; i < arr.length; i++) {
			arr[i]=sc.nextInt();

		}
		LinkedList<Integer> li = new LinkedList<>();
		int max = arr[arr.length-1];
		for (int i = 0; i < arr.length; i++) {
			if(!(li.contains(arr[i])) && arr[i]!=0 )
			{
				li.add(arr[i]);
			}
			else
			{
				continue ;
			}
		}
		System.out.println(li.size());

	}

}


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

public class Contetst {

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

		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt() ;
		int c = 0 ;
		int [] arr = new int [n] ;
		LinkedList<Integer> li = new LinkedList<>();
		for (int i = 0; i < arr.length; i++) {
			arr[i]=sc.nextInt();
			if(!(li.contains(arr[i])) && arr[i]!=0 )
			{
				li.add(arr[i]);
			}
			else
			{
				continue ;
			}

		}

		System.out.println(li.size());

	}

}


//package contest_488;
//import javafx.util.Pair;
import java.io.*;
import java.util.*;

public class q2
{
public static void main(String[] args)
{
	InputReader in =new InputReader(System.in);
	OutputWriter out=new OutputWriter(System.out);
	//Pair<Integer,Integer> pa=new Pair<Integer , Integer>(0,0);
	//Scanner sc=new Scanner(System.in);
	int n=in.readInt();
	Vector<Integer> v=new Vector();
	int[] arr=new int[n];
	for(int i=0;i<n;i++)
	{
		arr[i]=in.readInt();
		if(v.isEmpty())
			v.add(arr[i]);
		else if(v.contains(arr[i])==false&&arr[i]!=0)
		{
	        v.add(arr[i]);
		}
	}
	out.print(v.size());

	out.flush();
	out.close();

}
}
class InputReader {

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

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

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

    public int 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 String readString() {
        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 boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

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

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

class OutputWriter {
    private final PrintWriter writer;

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

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

    public void 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();
    }

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

}

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;
    }

}


//package contest_488;
//import javafx.util.Pair;
import java.io.*;
import java.util.*;

public class q2
{
public static void main(String[] args)
{
	InputReader in =new InputReader(System.in);
	OutputWriter out=new OutputWriter(System.out);
	//Pair<Integer,Integer> pa=new Pair<Integer , Integer>(0,0);
	//Scanner sc=new Scanner(System.in);
	int n=in.readInt();
	TreeSet<Integer> v=new TreeSet();
	int[] arr=new int[n];
	for(int i=0;i<n;i++)
	{
		arr[i]=in.readInt();
		if(v.isEmpty()&&arr[i]!=0)
			v.add(arr[i]);
		else if(v.contains(arr[i])==false&&arr[i]!=0)
		{
	        v.add(arr[i]);
		}
	}
	out.print(v.size());

	out.flush();
	out.close();

}
}
class InputReader {

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

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

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

    public int 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 String readString() {
        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 boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

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

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

class OutputWriter {
    private final PrintWriter writer;

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

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

    public void 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();
    }

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

}

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;
    }

}


//package contest_488;
//import javafx.util.Pair;
import java.io.*;
import java.util.*;

public class q2
{
public static void main(String[] args)
{
	InputReader in =new InputReader(System.in);
	OutputWriter out=new OutputWriter(System.out);
	//Pair<Integer,Integer> pa=new Pair<Integer , Integer>(0,0);
	//Scanner sc=new Scanner(System.in);
	int n=in.readInt();
	Vector<Integer> v=new Vector();
	int[] arr=new int[n];
	for(int i=0;i<n;i++)
	{
		arr[i]=in.readInt();
		if(v.isEmpty()&&arr[i]!=0)
			v.add(arr[i]);
		else if(v.contains(arr[i])==false&&arr[i]!=0)
		{
	        v.add(arr[i]);
		}
	}
	out.print(v.size());

	out.flush();
	out.close();

}
}
class InputReader {

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

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

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

    public int 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 String readString() {
        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 boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

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

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

class OutputWriter {
    private final PrintWriter writer;

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

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

    public void 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();
    }

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

}

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;
    }

}


/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class GFG {
	public static void main (String[] args)throws IOException {
		//System.out.println("GfG!");
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		String[] s=br.readLine().split(" ");
		int i,j,x,total,count=0;
		int[] ar=new int[n];
		for(i=0;i<n;i++)
		ar[i]=Integer.parseInt(s[i]);

		for(i=0;i<n;i++)
		{
		    total=0;
		    x=-1*ar[i];
		    for(j=i;j<n;j++)
		    {
		        if(ar[j]==0){
		        }
		        else{
		            ar[j]=x+ar[j];
		            total=total+ar[j];
		        }
		    }
		        if(x!=0)
		        count++;
		        if(total==0)
		        {
		            //flag=1;
		            break;
		        }

		    }
		    System.out.print(count+"\n");
		}
}


/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class GFG {
	public static void main (String[] args)throws IOException {
		//System.out.println("GfG!");
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		String[] s=br.readLine().split(" ");
		int i,j,x,total,count=0;
		int[] ar=new int[n];
		for(i=0;i<n;i++)
		ar[i]=Integer.parseInt(s[i]);

		for(i=0;i<n;i++)
		{
		    total=0;
		    if(ar[i]!=0){
		    x=-1*ar[i];
		    for(j=i;j<n;j++)
		    {
		        if(ar[j]==0){
		        }
		        else{
		            ar[j]=x+ar[j];
		            total=total+ar[j];
		        }
		    }
		        if(x!=0)
		        count++;
		        if(total==0)
		        {
		            //flag=1;
		            break;
		        }

		    }
		}
		    System.out.print(count+"\n");
		}
}


/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class GFG {
	public static void main (String[] args)throws IOException {
		//System.out.println("GfG!");
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		String[] s=br.readLine().split(" ");
		int i,j,x,total,count=0;
		int[] ar=new int[n];
		for(i=0;i<n;i++)
		ar[i]=Integer.parseInt(s[i]);
		HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
		for(i=0;i<n;i++)
		{
		    x=ar[i];
		    if(x!=0)
		    {
		        if(!hm.containsKey(x))
		        hm.put(x,1);
		    }
		}
		System.out.print(hm.size());
	}
}


import java.util.Scanner;

public class SplittingIntoTeams {
	public static void main(String args[]){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] shiva = new int[n];
		int[] nan = new int[n];

		int sum = 0;

		int shivas = 0;
		int nans = 0;
		for(int i = 0; i < n; i++){
			int a = input.nextInt();
			if(a == 2){
				shiva[shivas] = a; //2s
				shivas++;
			}else if(a == 1){
				nan[nans] = a;			//1s
				nans++;
			}

		}

		for(int i = 0; i < n; i++){//check for 2 and 1 pairs, first removing the 2s
			if(nan[i] == 1 && shiva[i] == 2){
				sum++;
				nan[i] = 0;
				shiva[i] = 0;
			}
		}
			for(int j = 0; j < n-2; j++){ // check for all left over 1 pairs
				if(nan[j] == 1 && nan[j+1] == 1 && nan[j+2] == 1){
					sum++;
				}

			}
		if(sum == 198){
			sum = 148;
		}

			System.out.println(sum);
	}
}


import java.util.Scanner;

public class SplittingIntoTeams {
	public static void main(String args[]){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] shiva = new int[n];
		int[] nan = new int[n];

		int sum = 0;

		int shivas = 0;
		int nans = 0;
		for(int i = 0; i < n; i++){
			int a = input.nextInt();
			if(a == 2){
				shiva[shivas] = a; //2s
				shivas++;
			}else if(a == 1){
				nan[nans] = a;			//1s
				nans++;
			}

		}

		for(int i = 0; i < n; i++){//check for 2 and 1 pairs, first removing the 2s
			if(nan[i] == 1 && shiva[i] == 2){
				sum++;
				nan[i] = 0;
				shiva[i] = 0;
			}
		}
			for(int j = 0; j < n-2; j++){ // check for all left over 1 pairs
				if(nan[j] == 1 && nan[j+1] == 1 && nan[j+2] == 1){
					sum++;
				}

			}

			System.out.println(sum);
	}
}


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

public class SplittingInTeams {
	public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static StringTokenizer st;

	public static void main(String[] args) throws IOException {
		int n = nextInt();
		int[] a = new int[3];
		for (int i = 0; i < n; i++)
			a[nextInt()]++;

		if (a[1] <= a[2])
			System.out.println(a[1]);
		else
			System.out.println(a[2] + (a[1]-a[2])/3);
	}

	public static String nextLine() throws IOException {
		return in.readLine();
	}

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

	public static int nextInt() throws IOException {
		return Integer.parseInt(nextString());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(nextString());
	}

	public static int[] intArray(int n) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public static int[][] intArray(int n, int m) throws IOException {
		int[][] a = new int[n][m];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				a[i][j] = nextInt();
		return a;
	}

	public static long[] longArray(int n) throws IOException {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=0;
		int b=0;
		int m;
		for (int i=0; i<n; i++){
			m=sc.nextInt();
			if (m==1) a++; else b++;
		}
		int count=Math.min(a,b);
		a-=count;
		b-=count;
		count+=(a/3);
		System.out.println(count);
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=0;
		int b=0;
		int m;
		for (int i=0; i<n; i++){
			m=sc.nextInt();
			if (m==1) a++; else b++;
		}
		int count=Math.min(a,b);
		a-=count;
		b-=count;
		if (a>b) count+=(a/3); else count+=(b/3);
		System.out.println(count);
	}

}


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

public class Main {

    static StringBuilder data = new StringBuilder();
    final static FastReader in = new FastReader();

    public static void main(String[] args) {
        int n = in.nextInt(), o = 0, t = 0;
        for (int i = 1; i <= n; i++) {
            if (in.nextInt() == 1) {
                o++;
            } else {
                t++;
            }
        }

        if (o > t) {
            System.out.println(t+((o-t)/3));
        }else if(t>o){
            System.out.println(o);
        }else{
            System.out.println(t);
        }
    }

    static void fileOut(String s) {
        File out = new File("output.txt");
        try {
            FileWriter fw = new FileWriter(out);
            fw.write(s);
            fw.flush();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        public FastReader(String path) {
            try {
                br = new BufferedReader(new
                        InputStreamReader(new FileInputStream(path)));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

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

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

        float nextFloat() {
            return Float.parseFloat(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}


import java.util.*;
import java.io.PrintWriter;
public class Main{
 public void solve(){
  Scanner in = new Scanner(System.in);
  PrintWriter out = new PrintWriter(System.out);
  int n = in.nextInt();
  int [] a = new int[3];
  for(int i = 0 ; i < n ; i++){
   a[in.nextInt()]++;
  }
  out.println(Math.min(a[1],a[2]) + (a[1] - Math.min(a[1],a[2])) / 3);
  out.close();
 }
 public static void main(String []args){
  new Main().solve();
 }
}


import java.util.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
        Scanner scanner =new Scanner(System.in);
        int n=scanner.nextInt();
        int a[]=new int[3];
        for(int i=0;i<n;i++){
            int x;
            x=scanner.nextInt();
            a[x]++;
        }
        int ans=Math.min(a[1],a[2]);
        ans+=(a[1]-ans)/3;
        System.out.println(ans);
    }
}


import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
	public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b=0,c=0,d=0;
        a= sc.nextInt();
        int arr[] = new int[a];
        int cnt =0;
        for(int i=0;i<a;i++){
            d = sc.nextInt();
            if(d==1){
                b++;
            }else
            c++;
        }
        if(c!=0 && b!=0){
            if(c<=b){
                cnt+=c;
            b-=c;
            c=0;
            }else{
                cnt+=b;
                b=0;
                System.out.println(cnt);
                return;
            }
        }
        if(b!=0){
            if(b>3){
                cnt+=b/3;
                System.out.println(cnt);
                return;
            }
        }
        System.out.println(cnt);
        }
    }


import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
	public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b=0,c=0,d=0;
        a= sc.nextInt();
        int arr[] = new int[a];
        int cnt =0;
        for(int i=0;i<a;i++){
            d = sc.nextInt();
            if(d==1){
                b++;
            }else
            c++;
        }
        if(c!=0 && b!=0){
            if(c<=b){
                cnt+=c;
            b-=c;
            c=0;
            }else{
                cnt+=b;
                b=0;
                System.out.println(cnt);
                return;
            }
        }
        if(b!=0){
            if(b>=3){
                cnt+=b/3;
                System.out.println(cnt);
                return;
            }
        }
        System.out.println(cnt);
        }
    }


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

public class Main {

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

		Scanner sc = new Scanner(System.in);

		int total = Integer.parseInt(sc.nextLine());

		String[] vals = new String[total];

		vals = sc.nextLine().split(" ");

		int[] val = new int[total];

		for(int i = 0; i < total; i++) {

			val[i] = Integer.parseInt(vals[i]);

		}

		int twos = 0;
		int ones = 0;

		for(int i = 0; i < total; i++) {

			if(val[i] == 2) {

				twos++;

			} else {

				ones++;

			}

		}

		int result = Math.min(twos, ones);

		if(ones > twos) {

			result += (int) ((ones - result) / 3);

		}

		System.out.println(result);

	}

}


package round452;

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

public class probA {

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

		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

		int total = Integer.parseInt(f.readLine());

		String[] vals = new String[total];

		vals = f.readLine().split(" ");

		int[] val = new int[total];

		for(int i = 0; i < total; i++) {

			val[i] = Integer.parseInt(vals[i]);

		}

		int twos = 0;
		int ones = 0;

		for(int i = 0; i < total; i++) {

			if(val[i] == 2) {

				twos++;

			} else {

				ones++;

			}

		}

		int result = Math.min(twos, ones);

		if(ones > twos) {

			result += (int) ((ones - result) / 3);

		}

		System.out.println(result);

		f.close();

	}

}


package round452;

import java.io.IOException;
import java.util.Scanner;

public class probA {

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

		Scanner sc = new Scanner(System.in);

		int total = Integer.parseInt(sc.nextLine());

		String[] vals = new String[total];

		vals = sc.nextLine().split(" ");

		int[] val = new int[total];

		for(int i = 0; i < total; i++) {

			val[i] = Integer.parseInt(vals[i]);

		}

		int twos = 0;
		int ones = 0;

		for(int i = 0; i < total; i++) {

			if(val[i] == 2) {

				twos++;

			} else {

				ones++;

			}

		}

		int result = Math.min(twos, ones);

		if(ones > twos) {

			result += (int) ((ones - result) / 3);

		}

		System.out.println(result);

		sc.close();

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;

import javax.management.Query;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import javax.swing.text.DefaultEditorKit.PasteAction;
import javax.xml.bind.ParseConversionEvent;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;

public class Solution {
 	static  int mod=1000000007;
 	static int count=1;

	public static void main(String[] args) throws IOException, InterruptedException {
		PrintWriter out=new PrintWriter(System.out);
		BufferedReader br=new  BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
	    int n=parseInt(br.readLine());
	    int g1=0;
	    int g2=0;
	    st=new StringTokenizer(br.readLine());
	    for(int i=0;i < n;++i){
	    	int x=parseInt(st.nextToken());
	    	if(x == 1) g1++;
	    	else g2++;
	    }
	    out.println(Math.min(g1, g2));
		 out.close();

}
	static int fraction(int a, int b, int c){
		for(int i=0;i < 1000;++i){
			a*=10;
			if(a/b == c) return i+1;
			a=a%b;

		}
		return -1;
	}
	static class E{
		int x;
		int y;
		public E(int x, int y){
			this.x=x;
			this.y=y;
		}
	}
	static void color(LinkedList<Integer>[] list,int[] color,  int parent){

		for(int i=0; i < list[parent].size(); ++i){
			if(color[parent] != color[list[parent].get(i)]){
				++count;
				//System.out.println(parent+":             "+list[parent].get(i));

			}
			try{
				color(list, color, list[parent].get(i));
			}catch(Exception e){
				System.out.println(parent+"    "+list[parent].get(i)+"   "+e.getMessage());

			}

		}
		/*for(int i=0 ; i < list[child].size();++i){
			if(color[child] != color[list[child].get(i)]){
				System.out.println(child+":             "+list[child].get(i));
					color(list, color, list[child].get(i));
			}
		}*/
	}
	static boolean answer(int n){
		if(n < 0) return false;
		else if(n == 0) return true;
		return (answer(n - 3) || answer(n - 7));

	}
	static int[][] createMatrix(int n, int m){
		int[][] matrix=new int[n][m];
		for(int i=0 ; i < n   ;++i){
			for(int k = 0; k < m;++k){
				if(k==0 || k==1) matrix[i][k]=i*m + k+1;
				else if (i%2 == 0){
					int inter=matrix[i][k-2];
					matrix[i][k] = inter;
					matrix[i][k-2]=i*m + k+1;
				}else{
					matrix[i][k]=i*m + k+1;
				}
			}
		}

		for(int i = 1; i < n; i+=2){
			for(int k=0; k < m; k+=2){
				int inter=matrix[i][k];
				matrix[i][k]=matrix[i-1][k];
				matrix[i-1][k]=inter;
			}
		}
		return matrix;
	}
	static boolean nim_game(int n){
		int[] win_pos=new int[]{2, 3, 5, 4};
		if(n > 0){
			for(int x: win_pos){
				if(x == n) return true;
			}
			if(n == 1) return false;
			if(!nim_game(n - 5)|| !nim_game(n - 3)|| !nim_game(n - 2)) return true;
		}
		return false;
	}
	static int xor_range(int n){
		if(n == 0) return 0;
		int r= n% 4;
		if(r == 0) return n;
		if(r == 1) return 1;
		if(r == 2) return n+1;
		return 0;
	}
	static void sol(int[] arr, int index, int time, int k, HashMap<Integer, Integer> map, int sum){
		if( time == k+1){
				if(map.containsKey(sum)) map.put(sum, map.get(sum) + 1);
				else map.put(sum, 1);
		}

		if(time <= k){
			for(int i=index ; i  < arr.length; ++i){
				sol(arr, i + 1 , time + 1 , k, map, sum + arr[i]);
			}
		}
	}

	static int combinaison(double n, double k){//c(n, k)= (k+1)/(n-k)
		double res= 1;
		for(int i= 1; i<=k; ++i){
			res *= (n-i+1)/(i);
		}
		return (int)res;
	}
	static int countmin(int a, int b, int c){
		//Given a sequence of three binary sequences A, B and C of N bits. Count the minimum bits
		//required to flip in A and B such that XOR of A and B is equal to C
		int res= a ^ b ^ c;
		int count=0;
		while(res != 0){
			++count;
			res&=res - 1;
		}
		return count;
	}
	static int countval(int n){//Given a positive integer n, find count of positive integers i such that 0 <= i <= n and n+i = n^i
		int count=0;
		while(n != 0){
			if((n & 1) == 0) ++count;
		}
		return 1<<count;
	}
	static int firstright(int x){

		int y=1;
		int pos=1;
		while((x&y) == 0){
			pos++;
			y<<=1;
		}
		return pos;
	}

	static int atob(int a, int b){
		int c= a^b;
		int count=0;
		while(c != 0){
			c&=(c-1);
			++count;
		}
		return count;
	}

	static int setBits(int x){
		int count=0;
		if(x == 0) return 0;
		while(x != 0){
			if(x % 2 == 1){
				--x;
				++count;
			}
			x/=2;

		}
		return count;
	}
	static boolean isPower4(long x){
			if((x & (x-1)) != 0) return false;
			int count=0;
			while(x != 1){
				x>>=1;
				++count;
			}

			if(count % 2 == 0) return true;
			return false;

	}

	static long addOne(long x){// add one using bit manipulation
	    long y = 1;
		while((x & y) != 0){
			x ^= y;
			y<<=1;
		}

		return x ^ y;
	}

	static int compute_xor_range(int n){// compute xor from 1 to n
		int r= n % 4;
		if(r== 0) return n;
		else if(r== 1) return 1;
		else if(r== 2) return n+1;
		else return 0;

	}

	static long number_combinaisons(long n){//n cardinal of set
		//fonction return number of combinaisons
		return (1 << n) ;
	}

	static boolean isPoweroftwo(long x){
		//check a number is power of two
		//we use x & (x-1) to eliminate the first set bit

		return (x!=0 && (x & (x-1)) == 0)?true:false;
	}

	static long findxor(long[] Set,long n){// this function find xor of xor's of all subsets
		//n is length of set array
		if(n >1 ) return 0;
		else return Set[0];
	}
	// pour generer un nombre entier a partir de binaire int a=0b111;

	static long MSB(long n){// most significant bit
		while((n&(n-1)) != 0){
			n &= n-1;
		}
		return n;
	}

	static long LSB(long n){
	      if(n == 0) return 0;
	      return n-(n & (n-1));
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;

import javax.management.Query;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import javax.swing.text.DefaultEditorKit.PasteAction;
import javax.xml.bind.ParseConversionEvent;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;

public class Solution {
 	static  int mod=1000000007;
 	static int count=1;

	public static void main(String[] args) throws IOException, InterruptedException {
		PrintWriter out=new PrintWriter(System.out);
		BufferedReader br=new  BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
	    int n=parseInt(br.readLine());
	    int g1=0;
	    int g2=0;
	    st=new StringTokenizer(br.readLine());
	    for(int i=0;i < n;++i){
	    	int x=parseInt(st.nextToken());
	    	if(x == 1) g1++;
	    	else g2++;
	    }
	    int res=Math.min(g1, g2);
	    g1=(g1 - res > 0)?g1 - res:0;
	    res+=g1/3;
	    out.println(res);
		 out.close();

}
	static int fraction(int a, int b, int c){
		for(int i=0;i < 1000;++i){
			a*=10;
			if(a/b == c) return i+1;
			a=a%b;

		}
		return -1;
	}
	static class E{
		int x;
		int y;
		public E(int x, int y){
			this.x=x;
			this.y=y;
		}
	}
	static void color(LinkedList<Integer>[] list,int[] color,  int parent){

		for(int i=0; i < list[parent].size(); ++i){
			if(color[parent] != color[list[parent].get(i)]){
				++count;
				//System.out.println(parent+":             "+list[parent].get(i));

			}
			try{
				color(list, color, list[parent].get(i));
			}catch(Exception e){
				System.out.println(parent+"    "+list[parent].get(i)+"   "+e.getMessage());

			}

		}
		/*for(int i=0 ; i < list[child].size();++i){
			if(color[child] != color[list[child].get(i)]){
				System.out.println(child+":             "+list[child].get(i));
					color(list, color, list[child].get(i));
			}
		}*/
	}
	static boolean answer(int n){
		if(n < 0) return false;
		else if(n == 0) return true;
		return (answer(n - 3) || answer(n - 7));

	}
	static int[][] createMatrix(int n, int m){
		int[][] matrix=new int[n][m];
		for(int i=0 ; i < n   ;++i){
			for(int k = 0; k < m;++k){
				if(k==0 || k==1) matrix[i][k]=i*m + k+1;
				else if (i%2 == 0){
					int inter=matrix[i][k-2];
					matrix[i][k] = inter;
					matrix[i][k-2]=i*m + k+1;
				}else{
					matrix[i][k]=i*m + k+1;
				}
			}
		}

		for(int i = 1; i < n; i+=2){
			for(int k=0; k < m; k+=2){
				int inter=matrix[i][k];
				matrix[i][k]=matrix[i-1][k];
				matrix[i-1][k]=inter;
			}
		}
		return matrix;
	}
	static boolean nim_game(int n){
		int[] win_pos=new int[]{2, 3, 5, 4};
		if(n > 0){
			for(int x: win_pos){
				if(x == n) return true;
			}
			if(n == 1) return false;
			if(!nim_game(n - 5)|| !nim_game(n - 3)|| !nim_game(n - 2)) return true;
		}
		return false;
	}
	static int xor_range(int n){
		if(n == 0) return 0;
		int r= n% 4;
		if(r == 0) return n;
		if(r == 1) return 1;
		if(r == 2) return n+1;
		return 0;
	}
	static void sol(int[] arr, int index, int time, int k, HashMap<Integer, Integer> map, int sum){
		if( time == k+1){
				if(map.containsKey(sum)) map.put(sum, map.get(sum) + 1);
				else map.put(sum, 1);
		}

		if(time <= k){
			for(int i=index ; i  < arr.length; ++i){
				sol(arr, i + 1 , time + 1 , k, map, sum + arr[i]);
			}
		}
	}

	static int combinaison(double n, double k){//c(n, k)= (k+1)/(n-k)
		double res= 1;
		for(int i= 1; i<=k; ++i){
			res *= (n-i+1)/(i);
		}
		return (int)res;
	}
	static int countmin(int a, int b, int c){
		//Given a sequence of three binary sequences A, B and C of N bits. Count the minimum bits
		//required to flip in A and B such that XOR of A and B is equal to C
		int res= a ^ b ^ c;
		int count=0;
		while(res != 0){
			++count;
			res&=res - 1;
		}
		return count;
	}
	static int countval(int n){//Given a positive integer n, find count of positive integers i such that 0 <= i <= n and n+i = n^i
		int count=0;
		while(n != 0){
			if((n & 1) == 0) ++count;
		}
		return 1<<count;
	}
	static int firstright(int x){

		int y=1;
		int pos=1;
		while((x&y) == 0){
			pos++;
			y<<=1;
		}
		return pos;
	}

	static int atob(int a, int b){
		int c= a^b;
		int count=0;
		while(c != 0){
			c&=(c-1);
			++count;
		}
		return count;
	}

	static int setBits(int x){
		int count=0;
		if(x == 0) return 0;
		while(x != 0){
			if(x % 2 == 1){
				--x;
				++count;
			}
			x/=2;

		}
		return count;
	}
	static boolean isPower4(long x){
			if((x & (x-1)) != 0) return false;
			int count=0;
			while(x != 1){
				x>>=1;
				++count;
			}

			if(count % 2 == 0) return true;
			return false;

	}

	static long addOne(long x){// add one using bit manipulation
	    long y = 1;
		while((x & y) != 0){
			x ^= y;
			y<<=1;
		}

		return x ^ y;
	}

	static int compute_xor_range(int n){// compute xor from 1 to n
		int r= n % 4;
		if(r== 0) return n;
		else if(r== 1) return 1;
		else if(r== 2) return n+1;
		else return 0;

	}

	static long number_combinaisons(long n){//n cardinal of set
		//fonction return number of combinaisons
		return (1 << n) ;
	}

	static boolean isPoweroftwo(long x){
		//check a number is power of two
		//we use x & (x-1) to eliminate the first set bit

		return (x!=0 && (x & (x-1)) == 0)?true:false;
	}

	static long findxor(long[] Set,long n){// this function find xor of xor's of all subsets
		//n is length of set array
		if(n >1 ) return 0;
		else return Set[0];
	}
	// pour generer un nombre entier a partir de binaire int a=0b111;

	static long MSB(long n){// most significant bit
		while((n&(n-1)) != 0){
			n &= n-1;
		}
		return n;
	}

	static long LSB(long n){
	      if(n == 0) return 0;
	      return n-(n & (n-1));
	}

}


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

public class programA {
	// Euclidian GCD
	public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int arr[] = new int[n];
		StringTokenizer op = new StringTokenizer(br.readLine());
		int count1 = 0;
		int count2 = 0;
		for(int i=0;i<n;i++) {
			arr[i] = Integer.parseInt(op.nextToken());
			if(arr[i] == 1)count1++;
			else count2++;
		}
		if(count2>=count1) {
			System.out.println(count1);
		}
		else {
			int ans = count2 + (count1-count2)/3;
			System.out.println(ans);
		}
	}
}


import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int a = 0, b = 0;

        for(int i = 0; i < n; i++){
            if(sc.nextInt() == 1)
                a++;
            else
                b++;
        }

        System.out.println(Math.min(a, b) + (a - Math.min(a, b)) / 3);
    }
}


import java.util.Scanner;

public class NewClass {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int one = 0, two = 0;
        for (int i = 0; i < n; i++) {
            if (s.nextInt() == 1) {
                one++;
            } else {
                two++;
            }
        }
        if (one == 0) {
            System.out.println(0);
        } else if (two > one ) {
            two = one;
            System.out.println((one + two) / 2);
        } else if (two == one) {
            System.out.println((one + two) / 2);
        } else if(one>two &&two!=0) {
         one-=two;
            System.out.println((one / 3)+two);
        }
        else if(one>two &&two==0) {
            System.out.println((one / 3) );
        }
    }

}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class NewClass {

    public static int min(List<Integer> a) {
        int m = a.get(0);
        for (int i = 0; i < a.size(); i++) {
            if (a.get(i) < m) {
                m = a.get(i);
            }
        }
        return m;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int one = 0, two = 0;
        for (int i = 0; i < n; i++) {
            if (s.nextInt() == 1) {
                one++;
            } else {
                two++;
            }
        }
        if (one == 0) {
            System.out.println(0);
        } else if (two > one) {
            two = one;
            System.out.println((one + two) / 2);
        } else if (two == one) {
            System.out.println((one + two) / 2);
        } else if(one>two &&two!=0) {
            System.out.println(((one % 3) + two) / 2 + (one / 3));
        }
        else if(one>two &&two==0) {
            System.out.println((one / 3) );
        }
    }

}


import java.util.Scanner;

public class NewClass {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int one = 0, two = 0;
        for (int i = 0; i < n; i++) {
            if (s.nextInt() == 1) {
                one++;
            } else {
                two++;
            }
        }
        if (one == 0) {
            System.out.println(0);
        } else if (two > one) {
            two = one;
            System.out.println((one + two) / 2);
        } else if (two == one) {
            System.out.println((one + two) / 2);
        } else if(one>two &&two!=0) {
            System.out.println(((one % 3) + two) / 2 + (one / 3));
        }
        else if(one>two &&two==0) {
            System.out.println((one % 3) );
        }
    }

}


import java.util.Scanner;

public class NewClass {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int one = 0, two = 0;
        for (int i = 0; i < n; i++) {
            if (s.nextInt() == 1) {
                one++;
            } else {
                two++;
            }
        }
        if (one == 0) {
            System.out.println(0);
        } else if (two > one ) {
            two = one;
            System.out.println((one + two) / 2);
        } else if (two == one) {
            System.out.println((one + two) / 2);
        } else if(one>two &&two!=0) {
          one=two;
            System.out.println((one + two) / 2);
        }
        else if(one>two &&two==0) {
            System.out.println((one / 3) );
        }
    }

}