/*
                                                                                                                                                `
                                                                                                                                                `
                                                                                                                                                `
                                                                                                                                                `
                                                                                                                                                `
                                                                                                                                                `
                                                                                                                                                `
                                                                                                                                                `
                                                                         `!!!;'                                                                 `
                                                           '%$@########################&&%:.                                                    `
                                                       .%###################################%.                                                  `
                                                    .`|######################################%                                                  `
                                                 .!@###############################################$'                                           `
                                              .!@#########################@@@#########################&;.                                       `
                                             :@##################@@@&&@@@$!!%&@@@@@@@###################&'                                      `
                                          :&################@@@&$%%||||!!:'':;!!||%|!%&@@#################%`                                    `
                                         |###############@@&&$%|!;;::::':'''':::;;!!|%%%$&&@###############$`                                   `
                                      :&#############@&$%||||!;'````````````'''```'':::'':!|$@@###############;                                 `
                                    :@#############@$$%|!;;;;:'``````...```...`...`'':::''';|%$$$&############&'                                `
                                   |##############&$$$%||!!;:'`````..````....`...```''::::;!!||$&&@@###########&'                               `
                                 !##############@$%|!!!;::'''`````...``.....`````````'''::::;;::!|%$&############|                              `
                                :@##########@&%!:'`::;;:'``....```.......  .``....````````````'':;!|%$@############;                            `
                               ;##########@%;```...`'''`...  .....    ................   .`.    `:!!!!%%%&#########|                            `
                              ;##########&|:.`'`. ..`...   .......   .....  ..  .....   ...   .'':!!:.`''!@#########|.                          `
                              !##########|'`.;!`       .  ......          ..    .      ....  .::'`. .. .`'|@########@:                          `
                              ;##########%'`'%!    ..       .  .                ..    .```.   ';:`..``.`':|@########@:                          `
                              !##########$:;$&;                     . `|%;.  `;||;::`.``';;.  .;!: `;:`';|$#########@!.                         `
                              !##########@$&@|. ...... .`':!|;` !$|%%'!##$' `|####$:`:;:!&$:. '$&!';!!||%&############;                         `
                             `$#############&:  `!!'`:;;;||%@&!'!&&$;.|##%`.|#####%`'$@$&##%` .:||;;;;%@##############!                         `
                             :@#############|. .!&@|;%@@@@@&@@#@&@#@&@############@@#####@:   .`'%@%!!&###############!                         `
                             :@############@;   :&@!;$###@|%|!$@@######################@%`    .;|!;!|%@###############!                         `
                             :@############@:   `$#$%#@@##&@################@$$$&$%|!'       `%#@|;':|&###############!                         `
                              !##########@$%:    |####@&######$;.                          ..`'`      ;@##############!                         `
                              !##########!       ;#########|.                             `;`         ;###############!                         `
                              ;##########;       `%######;                           '$###&:          `%@############&'                         `
                               !########@:       .'.       .:;`                   .|%:                   !##########&'                          `
                               !########@:                                                               ;#########@:                           `
                                !######%.     !##&;.        .                  `%&!`             '&###&' !#########!                            `
                                |#######;.%###!                 `!&###@|;;%@###%.    ';;|&$:;;`     |#%. .%###%$###!                            `
                               !#######|  `%#&'    |##&$####&:     !##########;    `%#####%.!#|.   .%@:   ;###;`%##!                            `
                                !#$!$##!   :@#!        .|###$'.    ;##|.  :&#@;    .``::`          ;@|.   :@#@: `$#|                            `
                                :&&|&##;   :&#!                   :&##;    .%##!                   !&'    ;@##!  |#!                            `
                                 |@@##@;  .`%#!                  '$##;      ;##$`                 :@!    .|##@; :&!                             `
                                 !&|&##%:'.  :&!                :@#%.        .%##;               |&!.   `|@!   `$!                              `
                                 '$%%###&;.   '&&'            `%##&'           |##@&:    ...;&&&@;     .;&#|':;$&:                              `
                                 .|######&;        '$@@@@@@@@#|                                        :&######%`                               `
                                   !#####&:                                                           '$#####@:                                 `
                                   '$#####@:                                                          ;#####$`                                  `
                                     '&####%.                 ``                                     '$#####;                                   `
                                      !#####$'                |@:  .:%|;;;;!$#####@#|               '&###$:                                     `
                                       :&####&:               ;####################@:    ':`       `%###@:                                      `
                                         ;#####@%:.                                         `'';|@######$`                                      `
                                         `$######@|`                                        !#&||@#####$`                                       `
                                          :&######@%'.                        .`''''` .';!|%@#@$$@####&:                                        `
                                           |######@|'.   ;##$!!%@##########################@:   '$####;                                         `
                                           :&#####$;''.`%#########&'             `|@$:         .%###@;                                          `
                                            :@####@;          |#@##&$;         `|%'           .|####!                                           `
                                              !####@;                                .        |####!                                            `
                                               :@###@|`         .                 `|!.       |####%.                                            `
                                                .|####!          `;$@%|!!!!!%&&@#$;.        !#####|                                             `
                                                .%####&:              '%&@@@|`             '&#####|                                             `
                                                .%#####|.                                 :&######%`                                            `
                                       :|||;`    !#######;                              .%#####@@#####@$;.                                      `
                                   `$#############&%!%#####|.                         :@####%:..'!&######@;                                     `
                                  `$#############|`..'%#######!                      ;####&;.    .'%#######!                                    `
                                .|##############@!`    .'%#########%'.          '%#####%`           :@#######@%;:.                              `
                          ;%|;. !############%::;'        `!&############@&&@#######@%'               !###########&'                            `
                         !################$'   .:'         '|&######################$:.               :@#############@@@@@@;                    `
                      ';$##&;:&###########$`                  :|$@################%:.                 !#####################@;                  `
                   '%####@$!:.  `%#########!                    .:!%&@#######@%!;'.                   |##############%!$@####!                  `
                .|#######&;'. .    |#######%.                      .':;!!!!!!;`...                   .|############|. :$@@####%.                `
                !####&$&@#@!:'.       ;#####%`                  .`';;'... ..''``.                    !##########%`    ''':$######$`             `
                ;#####@$$;`%&:.         `%####;                   .:;;:'':;||!:`                    !#########!          :&#@@####!             `
          '%######@######!   !!            :$@$`                    ...`.'::`..                   '$######@!`         '|$$&!!@#######@!.        `
     '$#########@&$$@######@:    ;: . `'    ....                      ...``.                    `$######&'           '!;`'!@######&&########$'  `
  ;############@#@@@@@$|%@###$`  `!!.;' .     :!.                                             .%#####!.            .;::&####|`..`  ..;@########!'
  |########&|;'``..`:'    ..!##%:.    ;;      `.                                            .|###|`             `'|###@&$|`  ..   .`|&&@#######%:
  |###@#@@#&|:`.`';;:;!!!;:;''!$##&;'.  .'%; .;&###&|$!                                     '$; .|$:;|`   ...;&###$'    ....      :||%&########%:
  |#######@$;!%%:```           .!@###&|`   :|'!########@#!                                ;@! :@####%'. `|@###&:         ..`:::%$$&$$$&@##@@@##|:
  |########$;::'`         .`.     `%#####%!: .. !#####%` !#%.                        !; '%; !#############&:          `::`.```. .':.  :$@&&&###|:
  !####@%:::;;:::::` .........            '.  !#######%;;';; `%#&'             ;&: `;``$@!%########&&##&|::::'.             ':.     `!%@@######|:
  !#####%;;::.       ...... ....`..  ..  '::!|&########$';%`.'` .;%:        !#$';$%|&$!&##########$'        `';;;;!&##&%||||||%;`   .:|&###@###|:
  |#######|`...      `|$&&$$!`....           ;$:  :&#@:     `'''``.   .%########&'  .%#@&$%$#####$`     ....`:%&@@@@@@&&@@!`.      .`'%@#######|'
  |######@@$:       .`..`!@&$&&&&:                ;@#######@@#$%@######&$;    '%@##%!@###@&&@####%.     `!&@@@@@$:..`..``.``...     `|&####@@##!'
  ;###&|;::!&#&%%%%:         .'::::;|$&&$%|'..;%%&#######%;$########@&#####%`   '|@###;    '%####$;::::::`            '!|%%%%%%%%%&#$:'::.'%###|'
  `%###@|;|%$%$@#&|;::::`          '|%%%%%$%|%|;';$##@|'.   |######&'     .:|$%: :&@|'.     !####%.              `::;:!$@######&%%%%%!'  ':;&##|:
  '$##%:.    :&##@####@$;.  ..                    `$|     :; !#####|      '|%:  ``    ...   !####!          .  ..:&#@@@@##@&||$;         :&####|'
  !####&@@&;        ...`.'%@##@@#@@&!`            :&&!.       !###&'  :||:.`   !%'     ``:$######@@@&&@@@&@##$;``....             |@@@@########!'
  !#######@$||!:          ';!;;;!&###&|||||||||||%&##@!`.     !###&||%!!!:   .:;`        `;;%####$;:;;;;;;;;;;;::.         '||||||&#####%!;;$##!`
  `%#&:.`:!||||||%@#@%;::;;;'                     ;@@:    .. .%###|.   `:::'  .:!;'`':'`   `$####!             ':;;;;!%@@&%%%|;`        `;%&###|:
  .%##|..       '$##@@@@@@#&:...`..              `$#$'        !##%`   ..`.`:%@@! '%@$:''. .`|####|... .........`:%###@#@@@|`        ....`%#####|:
  !###@&!       .`.```':!&##@&&&&$:              '&#%.        !#&'     ````.    .```:%&&&&&@#####@!':|$&&$&&&&&&&&&@##|`````.       !@@@#######!'
  :&#########@$||||:            `::::;;;;;!!;;;:;$###$'  .'`  |#@|.  .:;;:.                `%####%:''':::::`               `!||&##$;;;:::.  ;##|:
  .%#@$%$%%%%%$@###$::::::'.           ...`;|!::!&##@$%|||!' .%##&%%$%'        `'.         :&####!                  .':::'::%@&$%%!` .!!':;$###%:
  :&#############@|.              .  '$##################&;..!@###@#######%'.             .!#####!          .              `$#####@|``;&|!&####|:
  |####&%'   .''''':|@###@$$$$$$%;.             |####%`      .|#@;.         .;$$$%$&$$$$$$&######$:..:|%$$$$$$$&&&&@######&;'''.    ;$&########|:
  |#######@%;;`    '!|!||$#######&|!!!;;;!!!;`.!#####@: .;|!!|&#$'   `:'':;;$######################################%!|!!!!!;.  .`;|&######@####%:
  |############$!''''..';$&&&&@########################$;'!;`:@#&:``'|$@######@@@@&&&&&&&@#######@&&&&&&&&&&&@@&&&&$|:.    .`''$########@&@####%:
  |###&%$&#################@%;'  ..      `|@############$: `%@###########$`  `%%:.     . :@######|         !#####################@$%&##########%:
  |#######################################@&&@######################@@&@#######################################################################%:
*/

#define _CRT_SECURE_NO_WARNINGS

#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

inline char gc() {
    static const int L = 233333;
    static char sxd[L], *sss = sxd, *ttt = sxd;
    if (sss == ttt) {
        ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
        if (sss == ttt) {
            return EOF;
        }
    }
    return *sss++;
}

#ifndef _AT_HOME
#define dd c = gc()
#else
#define dd c = getchar()
#endif
inline char readalpha() {
    char dd;
    for (; !isalpha(c); dd);
    return c;
}

inline char readchar() {
    char dd;
    for (; c == ' '; dd);
    return c;
}

template <class T>
inline bool read(T& x) {
    bool flg = false;
    char dd;
    x = 0;
    for (; !isdigit(c); dd) {
        if (c == '-') {
            flg = true;
        } else if(c == EOF) {
            return false;
        }
    }
    for (; isdigit(c); dd) {
        x = (x * 10) + (c ^ 48);
    }
    if (flg) {
        x = -x;
    }
    return true;
}
#undef dd

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    if (x < 10) {
        putchar(x | 48);
        return;
    }
    write(x / 10);
    putchar((x % 10) | 48);
}

template <class T>
inline void writesp(T x) {
    write(x);
    putchar(' ');
}

template <class T>
inline void writeln(T x) {
    write(x);
    puts("");
}

namespace dfcmd {
    const int maxn = 1005;

    int n;
    double mp[maxn][maxn];
    int a[maxn][maxn];
    double b[maxn][maxn];

    struct Point {
        int x, y, z;
    } p[maxn];

    inline double dist(Point x, Point y) {
        return sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y));
    }

    int vis[maxn];
    double d[maxn];

    inline double prim() {
        double ans = 0;
        memset(vis, 0, sizeof(vis));
        d[1] = 0.;
        for (int i = 2; i <= n; ++i) {
            d[i] = 1e18;
        }
        for (int i = 1; i <= n; ++i) {
            int now = 0;
            for (int j = 1; j <= n; ++j) {
                if (!vis[j] && (!now || d[j] < d[now])) {
                    now = j;
                }
            }
            // cout << "now = " << now << endl;
            if (!now) {
                break;
            }
            ans += d[now];
            vis[now] = true;
            for (int j = 1; j <= n; ++j) {
                d[j] = min(d[j], mp[now][j]);
            }
        }
        // cout << "ans = " << ans << endl;
        return ans;
    }

    inline bool check(double l) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                mp[i][j] = a[i][j] - l * b[i][j];
                // cout << mp[i][j] << ' ';
            }
            // cout << endl;
        }
        return prim() <= 0;
    }

    inline void solve() {
        for (int i = 1; i <= n; ++i) {
            read(p[i].x), read(p[i].y), read(p[i].z);
        }
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                a[i][j] = abs(p[i].z - p[j].z);
                b[i][j] = dist(p[i], p[j]);
            }
        }
        // cout << check(0) << endl;
        // return;
        double l = 0., r = 1e18;
        while (r - l > 1e-4) {
            double mid = (l + r) / 2.;
            if (check(mid)) {
                r = mid;
            } else {
                l = mid;
            }
        }
        printf("%.3f\n", l);
    }

    int Main() {
        while (read(n) && n) {
            solve();
        }
        return 0;
    }
}

int main() {
    return dfcmd::Main();
}
