Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if 

  1. the sequence consists of at least two elements 
  2. f0 and f1 are arbitrary 
  3. fn + 2 = fn + 1 + fn for all n ≥ 0. 



You are given some sequence of integers a1, a2, ..., an. Your task is rearrange elements of this sequence in such a way that its longest possible prefix is Fibonacci-ish sequence.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 1000) — the length of the sequence ai.

The second line contains n integers a1, a2, ..., an (|ai| ≤ 109).

Output

Print the length of the longest possible Fibonacci-ish prefix of the given sequence after rearrangement.

Examples

Input

3
1 2 -1


Output

3


Input

5
28 35 7 14 21


Output

4

Note

In the first sample, if we rearrange elements of the sequence as  - 1, 2, 1, the whole sequence ai would be Fibonacci-ish.

In the second sample, the optimal way to rearrange elements is <image>, <image>, <image>, <image>, 28.
/**
 *
 * @author meashish
 */
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;

public class Main {

    InputReader in;
    Printer out;

    long MOD = 1000000007;

    private void start() throws Exception {
        int n = in.nextInt();

        long a[] = new long[n];
        
        HashMap<Long, HashSet<Long>> visited = new HashMap<>(1005);
        HashMap<Long, Integer> map = new HashMap<>();

        int ct0 = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextLong();
            
            visited.put(a[i], new HashSet<>(1005));
            
            if (a[i] == 0) {
                ct0++;
            }
            int ini = (map.containsKey(a[i]) ? map.get(a[i]) : 0);
            map.put(a[i], ini + 1);
        }

        int res = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j || visited.get(a[i]).contains(a[j])) {
                    continue;
                }
                
                visited.get(a[i]).add(a[j]);
                
                if (a[i] == 0 && a[j] == 0) {
                    res = Math.max(res, ct0);
                    continue;
                }
                
                ArrayList<Long> list = new ArrayList<>();
                list.add(a[i]);
                list.add(a[j]);
                map.put(a[i], map.get(a[i]) - 1);
                map.put(a[j], map.get(a[j]) - 1);

                int tmp = 2;
                long l = a[i], r = a[j];
                long s = l + r;

                boolean bool = false;
                if (map.containsKey(s)) {
                    int tt = map.get(s);
                    if (tt > 0) {
                        bool = true;
                        list.add(s);
                        map.put(s, tt - 1);
                    } else {
                        bool = false;
                    }
                } else {
                    bool = false;
                }

                //out.println(l + " " + r + " " + s + " " + bool);
                while (bool) {
                    tmp++;

                    l = r;
                    r = s;
                    s = l + r;
                    if (map.containsKey(s)) {
                        int tt = map.get(s);
                        if (tt > 0) {
                            bool = true;
                            list.add(s);
                            map.put(s, tt - 1);
                        } else {
                            bool = false;
                        }
                    } else {
                        bool = false;
                    }
                }

                list.stream().forEach((ll) -> {
                    int ini = (map.containsKey(ll) ? map.get(ll) : 0);
                    map.put(ll, ini + 1);
                });

                res = Math.max(res, tmp);
            }
        }

        out.println(res);
        out.flush();
    }

    void dfs(Node root) {
        out.print(root.val + " : ");
        for (Node ch : root.child) {
            if (ch != null) {
                out.print(ch.val + " ");
            }
        }
        out.println();
        for (Node ch : root.child) {
            if (ch != null) {
                dfs(ch);
            }
        }
    }

    class Node {

        char val;

        boolean bool = false;
        Node child[] = new Node[26];

        public Node(char val) {
            this.val = val;
        }
        int index = 0;
    }

    void add(String str, Node root, int ind) {
        Node cur = root;

        for (int i = 0; i < str.length(); i++) {
            int ch = str.charAt(i) - 'a';
            if (cur.child[ch] == null) {
                cur.child[ch] = new Node(str.charAt(i));
            }
            cur = cur.child[ch];
        }

        cur.bool = true;
        cur.index = ind;
    }

    boolean contains(String str, Node root) {
        Node cur = root;

        for (int i = 0; i < str.length(); i++) {
            int ch = str.charAt(i) - 'a';
            if (cur.child[ch] == null) {
                return false;
            }
            cur = cur.child[ch];
        }

        return cur.bool;
    }

    int get(String str, Node root) {
        Node cur = root;

        for (int i = 0; i < str.length(); i++) {
            int ch = str.charAt(i) - 'a';
            if (cur.child[ch] == null) {
                cur.child[ch] = new Node(str.charAt(i));
            }
            cur = cur.child[ch];
        }

        return cur.index;
    }

    BigInteger f(BigInteger b) {
        if (b == null) {
            return BigInteger.valueOf(0);
        }
        return b;
    }

    boolean check(int i, int n) {
        return i >= 0 && i < n;
    }

    long power(long x, long n) {
        if (n <= 0) {
            return 1;
        }
        long y = power(x, n / 2);

        if ((n & 1) == 1) {
            return (((y * y) % MOD) * x) % MOD;
        }

        return (y * y) % MOD;
    }

    public int gcd(int a, int b) {
        a = Math.abs(a);
        b = Math.abs(b);
        return BigInteger.valueOf(a).gcd(BigInteger.valueOf(b)).intValue();
    }

    public int[] input(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        return a;
    }

    public int[] range(int start, int end) {
        int range[] = new int[end - start];

        for (int i = start; i < end; i++) {
            range[i - start] = i;
        }

        return range;
    }

    public static void main(String[] args) throws Exception {
        InputReader in;
        PrintStream out;

        //in = new InputReader(new FileInputStream(new File("in.txt")));
        //out = new PrintStream("out.txt");
        in = new InputReader(System.in);
        out = System.out;

        Main main = new Main();

        main.in = in;
        main.out = new Printer(out);

        main.start();
    }

    private static 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 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 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 double nextDouble() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E') {
                    return res * Math.pow(10, nextInt());
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E') {
                        return res * Math.pow(10, nextInt());
                    }
                    if (c < '0' || c > '9') {
                        throw new InputMismatchException();
                    }
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

        public interface SpaceCharFilter {

            public boolean isSpaceChar(int ch);
        }
    }

    private static class Printer {

        PrintStream out;
        StringBuilder buffer = new StringBuilder();
        boolean autoFlush;

        public Printer(PrintStream out) {
            this.out = out;
        }

        public Printer(PrintStream out, boolean autoFlush) {
            this.out = out;
            this.autoFlush = autoFlush;
        }

        public void println() {
            buffer.append("\n");

            if (autoFlush) {
                flush();
            }
        }

        public void println(int n) {
            println(Integer.toString(n));
        }

        public void println(long n) {
            println(Long.toString(n));
        }

        public void println(double n) {
            println(Double.toString(n));
        }

        public void println(float n) {
            println(Float.toString(n));
        }

        public void println(boolean n) {
            println(Boolean.toString(n));
        }

        public void println(char n) {
            println(Character.toString(n));
        }

        public void println(byte n) {
            println(Byte.toString(n));
        }

        public void println(short n) {
            println(Short.toString(n));
        }

        public void println(Object o) {
            println(o.toString());
        }

        public void println(Object[] o) {
            println(Arrays.deepToString(o));
        }

        public void println(String s) {
            buffer.append(s).append("\n");

            if (autoFlush) {
                flush();
            }
        }

        public void print(char s) {
            buffer.append(s);

            if (autoFlush) {
                flush();
            }
        }

        public void print(String s) {
            buffer.append(s);

            if (autoFlush) {
                flush();
            }
        }

        public void flush() {
            try {
                BufferedWriter log = new BufferedWriter(new OutputStreamWriter(out));
                log.write(buffer.toString());

                log.flush();
                buffer = new StringBuilder();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private class Pair<T, U> implements Serializable {

        int x;
        int index;
        int ans = 0;
        private T key;

        public T getKey() {
            return key;
        }

        private U value;

        public U getValue() {
            return value;
        }

        public Pair(T key, U value) {
            this.key = key;
            this.value = value;
        }

        @Override
        public String toString() {
            return key + "=" + value;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }

            final Pair other = (Pair) obj;
            if (!this.key.equals(other.key)) {
                return false;
            }

            return this.value.equals(other.value);
        }

        @Override
        public int hashCode() {
            return key.hashCode() + 13 * value.hashCode();
        }
    }

    static ArrayList<int[]> permutations(int[] arr) {
        final ArrayList<int[]> resultList = new ArrayList<int[]>();
        final int l = arr.length;
        if (l == 0) {
            return resultList;
        }
        if (l == 1) {
            resultList.add(arr);
            return resultList;
        }

        int[] subClone = Arrays.copyOf(arr, l - 1);
        System.arraycopy(arr, 1, subClone, 0, l - 1);

        for (int i = 0; i < l; ++i) {
            int e = arr[i];
            if (i > 0) {
                subClone[i - 1] = arr[0];
            }
            final ArrayList<int[]> subPermutations = permutations(subClone);
            for (int[] sc : subPermutations) {
                int[] clone = Arrays.copyOf(arr, l);
                clone[0] = e;
                System.arraycopy(sc, 0, clone, 1, l - 1);
                resultList.add(clone);
            }
            if (i > 0) {
                subClone[i - 1] = e;
            }
        }
        return resultList;
    }

    private class Bit {

        int N;
        long ft[] = new long[10000000];

        Bit(int n) {
            N = n;
        }

        void update(int p, long v) {
            for (; p <= N; p += p & (-p)) {
                ft[p] += v;
                ft[p] %= MOD;
            }
        }

        void update(int a, int b, long v) {
            update(a, v);
            update(b + 1, -v);
        }

        long query(int b) {
            long sum = 0;
            for (; b > 0; b -= b & (-b)) {
                sum += ft[b];
                sum %= MOD;
            }

            return sum;
        }
    }
}